Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gapic-generator-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<clirr.skip>true</clirr.skip>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Should be in sync with repositories.bzl -->
<googleapis.commit>44d6bef0ca6db8bba3fb324c8186e694bcc4829c</googleapis.commit>
<googleapis.commit>9fcfbea0aa5b50fa22e190faceb073d74504172b</googleapis.commit>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably a tech debt on our end. gapic_metadata.proto should be updated automatically along side other "config protos" like service.proto.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, agreed. I will leave this here for now, but LMK if you want me to file a tracking issue with some details.

<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1898,12 +1898,15 @@ private static void updateGapicMetadata(
serviceClientProtoBuilder.putRpcs(rpcName, methodList);
}

metadataBuilder =
metadataBuilder.putServices(
service.name(),
GapicMetadata.ServiceForTransport.newBuilder()
.putClients("grpc", serviceClientProtoBuilder.build())
.build());
GapicMetadata.ServiceForTransport.Builder grpcServiceClient =
GapicMetadata.ServiceForTransport.newBuilder()
.putClients("grpc", serviceClientProtoBuilder.build());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@blakeli0 Do you know why if there is a reason we don't have a "rest" client here as well?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was probably a miss when REGAPIC was implemented.
This maybe outside of the scope of this PR, @noahdietz do you have any concerns of not having rest in gapic_metadata.json?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you have any concerns of not having rest in gapic_metadata.json?

ATM, i have no concerns. In my survey of other languages, Java is not the only one. We've gone X years without publishing that metadata with no complaints, so I'm not sure it's all that urgent. I can file an idea bug to capture my findings across languages and at least document that there is a gap in the metadata for rest.


if (service.hasApiVersion()) {
grpcServiceClient.setApiVersion(service.apiVersion());
}

metadataBuilder = metadataBuilder.putServices(service.name(), grpcServiceClient.build());
context.updateGapicMetadata(metadataBuilder.build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.google.api.gax.rpc.StatusCode;
import com.google.common.collect.Lists;
import com.google.protobuf.AbstractMessage;
import com.google.protobuf.Empty;
import com.google.protobuf.FieldMask;
import google.cloud.ProjectName;
import io.grpc.StatusRuntimeException;
import java.io.IOException;
Expand Down Expand Up @@ -79,6 +80,8 @@ public class SubscriberClientTest {
.setName(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString())
.setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
.setPushConfig(PushConfig.newBuilder().build())
.setBigqueryConfig(BigQueryConfig.newBuilder().build())
.setCloudStorageConfig(CloudStorageConfig.newBuilder().build())
.setAckDeadlineSeconds(2135351438)
.setRetainAckedMessages(true)
.putAllLabels(new HashMap<String, String>())
Expand All @@ -89,6 +92,10 @@ public class SubscriberClientTest {
.setRetryPolicy(RetryPolicy.newBuilder().build())
.setDetached(true)
.setEnableExactlyOnceDelivery(true)
.setAnalyticsHubSubscriptionInfo(
Subscription.AnalyticsHubSubscriptionInfo.newBuilder().build())
.addAllMessageTransforms(new ArrayList<MessageTransform>())
.putAllTags(new HashMap<String, String>())
.build();
mockSubscriber.addResponse(expectedResponse);

Expand Down Expand Up @@ -139,6 +146,8 @@ public class SubscriberClientTest {
.setName(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString())
.setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
.setPushConfig(PushConfig.newBuilder().build())
.setBigqueryConfig(BigQueryConfig.newBuilder().build())
.setCloudStorageConfig(CloudStorageConfig.newBuilder().build())
.setAckDeadlineSeconds(2135351438)
.setRetainAckedMessages(true)
.putAllLabels(new HashMap<String, String>())
Expand All @@ -149,6 +158,10 @@ public class SubscriberClientTest {
.setRetryPolicy(RetryPolicy.newBuilder().build())
.setDetached(true)
.setEnableExactlyOnceDelivery(true)
.setAnalyticsHubSubscriptionInfo(
Subscription.AnalyticsHubSubscriptionInfo.newBuilder().build())
.addAllMessageTransforms(new ArrayList<MessageTransform>())
.putAllTags(new HashMap<String, String>())
.build();
mockSubscriber.addResponse(expectedResponse);

Expand Down Expand Up @@ -199,6 +212,8 @@ public class SubscriberClientTest {
.setName(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString())
.setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
.setPushConfig(PushConfig.newBuilder().build())
.setBigqueryConfig(BigQueryConfig.newBuilder().build())
.setCloudStorageConfig(CloudStorageConfig.newBuilder().build())
.setAckDeadlineSeconds(2135351438)
.setRetainAckedMessages(true)
.putAllLabels(new HashMap<String, String>())
Expand All @@ -209,6 +224,10 @@ public class SubscriberClientTest {
.setRetryPolicy(RetryPolicy.newBuilder().build())
.setDetached(true)
.setEnableExactlyOnceDelivery(true)
.setAnalyticsHubSubscriptionInfo(
Subscription.AnalyticsHubSubscriptionInfo.newBuilder().build())
.addAllMessageTransforms(new ArrayList<MessageTransform>())
.putAllTags(new HashMap<String, String>())
.build();
mockSubscriber.addResponse(expectedResponse);

Expand Down Expand Up @@ -259,6 +278,8 @@ public class SubscriberClientTest {
.setName(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString())
.setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
.setPushConfig(PushConfig.newBuilder().build())
.setBigqueryConfig(BigQueryConfig.newBuilder().build())
.setCloudStorageConfig(CloudStorageConfig.newBuilder().build())
.setAckDeadlineSeconds(2135351438)
.setRetainAckedMessages(true)
.putAllLabels(new HashMap<String, String>())
Expand All @@ -269,6 +290,10 @@ public class SubscriberClientTest {
.setRetryPolicy(RetryPolicy.newBuilder().build())
.setDetached(true)
.setEnableExactlyOnceDelivery(true)
.setAnalyticsHubSubscriptionInfo(
Subscription.AnalyticsHubSubscriptionInfo.newBuilder().build())
.addAllMessageTransforms(new ArrayList<MessageTransform>())
.putAllTags(new HashMap<String, String>())
.build();
mockSubscriber.addResponse(expectedResponse);

Expand Down Expand Up @@ -319,6 +344,8 @@ public class SubscriberClientTest {
.setName(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString())
.setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
.setPushConfig(PushConfig.newBuilder().build())
.setBigqueryConfig(BigQueryConfig.newBuilder().build())
.setCloudStorageConfig(CloudStorageConfig.newBuilder().build())
.setAckDeadlineSeconds(2135351438)
.setRetainAckedMessages(true)
.putAllLabels(new HashMap<String, String>())
Expand All @@ -329,6 +356,10 @@ public class SubscriberClientTest {
.setRetryPolicy(RetryPolicy.newBuilder().build())
.setDetached(true)
.setEnableExactlyOnceDelivery(true)
.setAnalyticsHubSubscriptionInfo(
Subscription.AnalyticsHubSubscriptionInfo.newBuilder().build())
.addAllMessageTransforms(new ArrayList<MessageTransform>())
.putAllTags(new HashMap<String, String>())
.build();
mockSubscriber.addResponse(expectedResponse);

Expand Down Expand Up @@ -369,6 +400,8 @@ public class SubscriberClientTest {
.setName(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString())
.setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
.setPushConfig(PushConfig.newBuilder().build())
.setBigqueryConfig(BigQueryConfig.newBuilder().build())
.setCloudStorageConfig(CloudStorageConfig.newBuilder().build())
.setAckDeadlineSeconds(2135351438)
.setRetainAckedMessages(true)
.putAllLabels(new HashMap<String, String>())
Expand All @@ -379,6 +412,10 @@ public class SubscriberClientTest {
.setRetryPolicy(RetryPolicy.newBuilder().build())
.setDetached(true)
.setEnableExactlyOnceDelivery(true)
.setAnalyticsHubSubscriptionInfo(
Subscription.AnalyticsHubSubscriptionInfo.newBuilder().build())
.addAllMessageTransforms(new ArrayList<MessageTransform>())
.putAllTags(new HashMap<String, String>())
.build();
mockSubscriber.addResponse(expectedResponse);

Expand Down Expand Up @@ -419,6 +456,8 @@ public class SubscriberClientTest {
.setName(SubscriptionName.of("[PROJECT]", "[SUBSCRIPTION]").toString())
.setTopic(TopicName.ofProjectTopicName("[PROJECT]", "[TOPIC]").toString())
.setPushConfig(PushConfig.newBuilder().build())
.setBigqueryConfig(BigQueryConfig.newBuilder().build())
.setCloudStorageConfig(CloudStorageConfig.newBuilder().build())
.setAckDeadlineSeconds(2135351438)
.setRetainAckedMessages(true)
.putAllLabels(new HashMap<String, String>())
Expand All @@ -429,23 +468,25 @@ public class SubscriberClientTest {
.setRetryPolicy(RetryPolicy.newBuilder().build())
.setDetached(true)
.setEnableExactlyOnceDelivery(true)
.setAnalyticsHubSubscriptionInfo(
Subscription.AnalyticsHubSubscriptionInfo.newBuilder().build())
.addAllMessageTransforms(new ArrayList<MessageTransform>())
.putAllTags(new HashMap<String, String>())
.build();
mockSubscriber.addResponse(expectedResponse);

UpdateSubscriptionRequest request =
UpdateSubscriptionRequest.newBuilder()
.setSubscription(Subscription.newBuilder().build())
.build();
Subscription subscription = Subscription.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();

Subscription actualResponse = client.updateSubscription(request);
Subscription actualResponse = client.updateSubscription(subscription, updateMask);
Assert.assertEquals(expectedResponse, actualResponse);

List<AbstractMessage> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateSubscriptionRequest actualRequest = ((UpdateSubscriptionRequest) actualRequests.get(0));

Assert.assertEquals(request.getSubscription(), actualRequest.getSubscription());
Assert.assertEquals(request.getUpdateMask(), actualRequest.getUpdateMask());
Assert.assertEquals(subscription, actualRequest.getSubscription());
Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
Expand All @@ -458,11 +499,9 @@ public class SubscriberClientTest {
mockSubscriber.addException(exception);

try {
UpdateSubscriptionRequest request =
UpdateSubscriptionRequest.newBuilder()
.setSubscription(Subscription.newBuilder().build())
.build();
client.updateSubscription(request);
Subscription subscription = Subscription.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
client.updateSubscription(subscription, updateMask);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
Expand Down Expand Up @@ -946,7 +985,7 @@ public class SubscriberClientTest {
StreamingPullResponse expectedResponse =
StreamingPullResponse.newBuilder()
.addAllReceivedMessages(new ArrayList<ReceivedMessage>())
.setAcknowlegeConfirmation(
.setAcknowledgeConfirmation(
StreamingPullResponse.AcknowledgeConfirmation.newBuilder().build())
.setModifyAckDeadlineConfirmation(
StreamingPullResponse.ModifyAckDeadlineConfirmation.newBuilder().build())
Expand All @@ -964,6 +1003,7 @@ public class SubscriberClientTest {
.setClientId("clientId908408390")
.setMaxOutstandingMessages(-1315266996)
.setMaxOutstandingBytes(-2103098517)
.setProtocolVersion(-1161610703)
.build();

MockStreamObserver<StreamingPullResponse> responseObserver = new MockStreamObserver<>();
Expand Down Expand Up @@ -995,6 +1035,7 @@ public class SubscriberClientTest {
.setClientId("clientId908408390")
.setMaxOutstandingMessages(-1315266996)
.setMaxOutstandingBytes(-2103098517)
.setProtocolVersion(-1161610703)
.build();

MockStreamObserver<StreamingPullResponse> responseObserver = new MockStreamObserver<>();
Expand Down Expand Up @@ -1440,18 +1481,18 @@ public class SubscriberClientTest {
.build();
mockSubscriber.addResponse(expectedResponse);

UpdateSnapshotRequest request =
UpdateSnapshotRequest.newBuilder().setSnapshot(Snapshot.newBuilder().build()).build();
Snapshot snapshot = Snapshot.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();

Snapshot actualResponse = client.updateSnapshot(request);
Snapshot actualResponse = client.updateSnapshot(snapshot, updateMask);
Assert.assertEquals(expectedResponse, actualResponse);

List<AbstractMessage> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateSnapshotRequest actualRequest = ((UpdateSnapshotRequest) actualRequests.get(0));

Assert.assertEquals(request.getSnapshot(), actualRequest.getSnapshot());
Assert.assertEquals(request.getUpdateMask(), actualRequest.getUpdateMask());
Assert.assertEquals(snapshot, actualRequest.getSnapshot());
Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
Expand All @@ -1464,9 +1505,9 @@ public class SubscriberClientTest {
mockSubscriber.addException(exception);

try {
UpdateSnapshotRequest request =
UpdateSnapshotRequest.newBuilder().setSnapshot(Snapshot.newBuilder().build()).build();
client.updateSnapshot(request);
Snapshot snapshot = Snapshot.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
client.updateSnapshot(snapshot, updateMask);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import com.google.logging.v2.LoggingProto;
import com.google.protobuf.Descriptors.FileDescriptor;
import com.google.protobuf.Descriptors.ServiceDescriptor;
import com.google.protobuf.EmptyProto;
import com.google.showcase.v1beta1.EchoOuterClass;
import com.google.showcase.v1beta1.TestingOuterClass;
import com.google.test.collisions.CollisionsOuterClass;
Expand Down Expand Up @@ -143,6 +144,12 @@ void generateResourceNameClass_loggingOnePatternMultipleVariables() {
FileDescriptor commonResourcesFileDescriptor = CommonResources.getDescriptor();
resourceNames.putAll(Parser.parseResourceNames(commonResourcesFileDescriptor));

// Additional dependency found in LoggingService.DeleteLink LRO
// (google.longrunning.operation_info).response_type. Necessary for
// complete parsing of the descriptors.
FileDescriptor emptyFileDescriptor = EmptyProto.getDescriptor();
messageTypes.putAll(Parser.parseMessages(emptyFileDescriptor));

Set<ResourceName> outputResourceNames = new HashSet<>();
Parser.parseService(
serviceFileDescriptor, messageTypes, resourceNames, Optional.empty(), outputResourceNames);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@
}
}
}
}
},
"apiVersion": "v1_20240408"
},
"Identity": {
"clients": {
Expand Down
Loading