Skip to content

Commit 8bcbe26

Browse files
feat: Allow regional path creation for when the backend supports this (#881)
1 parent 22db237 commit 8bcbe26

File tree

3 files changed

+13
-35
lines changed

3 files changed

+13
-35
lines changed

google-cloud-pubsublite/clirr-ignored-differences.xml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,28 @@
22
<!-- see http://www.mojohaus.org/clirr-maven-plugin/examples/ignored-differences.html -->
33
<differences>
44
<!-- TODO: Remove on next release -->
5+
<!-- Clirr doesn't understand CRTP -->
56
<difference>
6-
<differenceType>7005</differenceType>
7-
<className>com/google/cloud/pubsublite/AdminClient</className>
7+
<differenceType>7006</differenceType>
8+
<className>com/google/cloud/pubsublite/SubscriptionPath$Builder</className>
89
<method>*</method>
910
<to>*</to>
1011
</difference>
11-
<difference>
12-
<differenceType>8001</differenceType>
13-
<className>com/google/cloud/pubsublite/AdminClient*</className>
14-
</difference>
1512
<difference>
1613
<differenceType>7006</differenceType>
17-
<className>com/google/cloud/pubsublite/SubscriptionPath</className>
14+
<className>com/google/cloud/pubsublite/TopicPath$Builder</className>
1815
<method>*</method>
1916
<to>*</to>
2017
</difference>
2118
<difference>
22-
<differenceType>7006</differenceType>
23-
<className>com/google/cloud/pubsublite/TopicPath</className>
19+
<differenceType>7002</differenceType>
20+
<className>com/google/cloud/pubsublite/SubscriptionPath$Builder</className>
21+
<method>*</method>
22+
</difference>
23+
<difference>
24+
<differenceType>7002</differenceType>
25+
<className>com/google/cloud/pubsublite/TopicPath$Builder</className>
2426
<method>*</method>
25-
<to>*</to>
2627
</difference>
2728
<!-- END TODO: Remove on next release -->
2829
<!-- Added method to AdminClient interface (Always okay) -->

google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/SubscriptionPath.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import com.google.api.gax.rpc.ApiException;
2222
import com.google.auto.value.AutoValue;
23-
import com.google.cloud.pubsublite.CloudRegionOrZone.Kind;
2423
import java.io.Serializable;
2524
import java.util.Arrays;
2625

@@ -54,14 +53,7 @@ public static Builder newBuilder() {
5453
public abstract Builder toBuilder();
5554

5655
@AutoValue.Builder
57-
public abstract static class Builder extends ProjectBuilderHelper<Builder> {
58-
// TODO(dpcollins): Make this public and use ProjectLocationBuilderHelper once region is allowed
59-
abstract Builder setLocation(CloudRegionOrZone location);
60-
61-
public Builder setLocation(CloudZone zone) {
62-
return setLocation(CloudRegionOrZone.of(zone));
63-
}
64-
56+
public abstract static class Builder extends ProjectLocationBuilderHelper<Builder> {
6557
public abstract Builder setName(SubscriptionName name);
6658

6759
/** Build a new SubscriptionPath. */
@@ -73,10 +65,6 @@ public static SubscriptionPath parse(String path) throws ApiException {
7365
checkArgument(splits.length == 6);
7466
checkArgument(splits[4].equals("subscriptions"));
7567
LocationPath location = LocationPath.parse(String.join("/", Arrays.copyOf(splits, 4)));
76-
// TODO(dpcollins): Remove once region is allowed
77-
checkArgument(
78-
location.location().getKind() == Kind.ZONE,
79-
"Subscription location must be a valid cloud zone.");
8068
return SubscriptionPath.newBuilder()
8169
.setProject(location.project())
8270
.setLocation(location.location())

google-cloud-pubsublite/src/main/java/com/google/cloud/pubsublite/TopicPath.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import com.google.api.gax.rpc.ApiException;
2222
import com.google.auto.value.AutoValue;
23-
import com.google.cloud.pubsublite.CloudRegionOrZone.Kind;
2423
import java.io.Serializable;
2524
import java.util.Arrays;
2625

@@ -54,14 +53,7 @@ public static Builder newBuilder() {
5453
public abstract Builder toBuilder();
5554

5655
@AutoValue.Builder
57-
public abstract static class Builder extends ProjectBuilderHelper<Builder> {
58-
// TODO(dpcollins): Make this public and use ProjectLocationBuilderHelper once region is allowed
59-
abstract Builder setLocation(CloudRegionOrZone location);
60-
61-
public Builder setLocation(CloudZone zone) {
62-
return setLocation(CloudRegionOrZone.of(zone));
63-
}
64-
56+
public abstract static class Builder extends ProjectLocationBuilderHelper<Builder> {
6557
public abstract Builder setName(TopicName name);
6658

6759
/** Build a new TopicPath. */
@@ -73,9 +65,6 @@ public static TopicPath parse(String path) throws ApiException {
7365
checkArgument(splits.length == 6);
7466
checkArgument(splits[4].equals("topics"));
7567
LocationPath location = LocationPath.parse(String.join("/", Arrays.copyOf(splits, 4)));
76-
// TODO(dpcollins): Remove once region is allowed
77-
checkArgument(
78-
location.location().getKind() == Kind.ZONE, "Topic location must be a valid cloud zone.");
7968
return TopicPath.newBuilder()
8069
.setProject(location.project())
8170
.setLocation(location.location())

0 commit comments

Comments
 (0)