Skip to content

Commit

Permalink
feat: Allow regional path creation for when the backend supports this (
Browse files Browse the repository at this point in the history
  • Loading branch information
dpcollins-google committed Sep 15, 2021
1 parent 22db237 commit 8bcbe26
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 35 deletions.
21 changes: 11 additions & 10 deletions google-cloud-pubsublite/clirr-ignored-differences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@
<!-- see http://www.mojohaus.org/clirr-maven-plugin/examples/ignored-differences.html -->
<differences>
<!-- TODO: Remove on next release -->
<!-- Clirr doesn't understand CRTP -->
<difference>
<differenceType>7005</differenceType>
<className>com/google/cloud/pubsublite/AdminClient</className>
<differenceType>7006</differenceType>
<className>com/google/cloud/pubsublite/SubscriptionPath$Builder</className>
<method>*</method>
<to>*</to>
</difference>
<difference>
<differenceType>8001</differenceType>
<className>com/google/cloud/pubsublite/AdminClient*</className>
</difference>
<difference>
<differenceType>7006</differenceType>
<className>com/google/cloud/pubsublite/SubscriptionPath</className>
<className>com/google/cloud/pubsublite/TopicPath$Builder</className>
<method>*</method>
<to>*</to>
</difference>
<difference>
<differenceType>7006</differenceType>
<className>com/google/cloud/pubsublite/TopicPath</className>
<differenceType>7002</differenceType>
<className>com/google/cloud/pubsublite/SubscriptionPath$Builder</className>
<method>*</method>
</difference>
<difference>
<differenceType>7002</differenceType>
<className>com/google/cloud/pubsublite/TopicPath$Builder</className>
<method>*</method>
<to>*</to>
</difference>
<!-- END TODO: Remove on next release -->
<!-- Added method to AdminClient interface (Always okay) -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import com.google.api.gax.rpc.ApiException;
import com.google.auto.value.AutoValue;
import com.google.cloud.pubsublite.CloudRegionOrZone.Kind;
import java.io.Serializable;
import java.util.Arrays;

Expand Down Expand Up @@ -54,14 +53,7 @@ public static Builder newBuilder() {
public abstract Builder toBuilder();

@AutoValue.Builder
public abstract static class Builder extends ProjectBuilderHelper<Builder> {
// TODO(dpcollins): Make this public and use ProjectLocationBuilderHelper once region is allowed
abstract Builder setLocation(CloudRegionOrZone location);

public Builder setLocation(CloudZone zone) {
return setLocation(CloudRegionOrZone.of(zone));
}

public abstract static class Builder extends ProjectLocationBuilderHelper<Builder> {
public abstract Builder setName(SubscriptionName name);

/** Build a new SubscriptionPath. */
Expand All @@ -73,10 +65,6 @@ public static SubscriptionPath parse(String path) throws ApiException {
checkArgument(splits.length == 6);
checkArgument(splits[4].equals("subscriptions"));
LocationPath location = LocationPath.parse(String.join("/", Arrays.copyOf(splits, 4)));
// TODO(dpcollins): Remove once region is allowed
checkArgument(
location.location().getKind() == Kind.ZONE,
"Subscription location must be a valid cloud zone.");
return SubscriptionPath.newBuilder()
.setProject(location.project())
.setLocation(location.location())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import com.google.api.gax.rpc.ApiException;
import com.google.auto.value.AutoValue;
import com.google.cloud.pubsublite.CloudRegionOrZone.Kind;
import java.io.Serializable;
import java.util.Arrays;

Expand Down Expand Up @@ -54,14 +53,7 @@ public static Builder newBuilder() {
public abstract Builder toBuilder();

@AutoValue.Builder
public abstract static class Builder extends ProjectBuilderHelper<Builder> {
// TODO(dpcollins): Make this public and use ProjectLocationBuilderHelper once region is allowed
abstract Builder setLocation(CloudRegionOrZone location);

public Builder setLocation(CloudZone zone) {
return setLocation(CloudRegionOrZone.of(zone));
}

public abstract static class Builder extends ProjectLocationBuilderHelper<Builder> {
public abstract Builder setName(TopicName name);

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

0 comments on commit 8bcbe26

Please sign in to comment.