Skip to content

Commit 8671525

Browse files
feat: Introduce the event publishing using JSON representation of CloudEvents (#170)
- [ ] Regenerate this pull request now. Clients can now use either the Protobuf or the JSON CloudEvents representation when interacting with Eventarc Publishing API. This change benefits both Channel and ChannelConnection consumers. PiperOrigin-RevId: 486208303 Source-Link: https://togithub.com/googleapis/googleapis/commit/079ef843a85546a6d352f8936f5a8442c60f9601 Source-Link: https://togithub.com/googleapis/googleapis-gen/commit/dd62dfc174abb25bf2e50a2a54651da70daed781 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZGQ2MmRmYzE3NGFiYjI1YmYyZTUwYTJhNTQ2NTFkYTcwZGFlZDc4MSJ9 BEGIN_NESTED_COMMIT chore: Set `rest_numeric_enums = False` for all gapic rules explicitly PiperOrigin-RevId: 485623855 Source-Link: https://togithub.com/googleapis/googleapis/commit/807125e7953e32535710924fe4bf0362ac93754d Source-Link: https://togithub.com/googleapis/googleapis-gen/commit/c4ddd6d651da69658a4762c5eafff5cd8f0e25c5 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYzRkZGQ2ZDY1MWRhNjk2NThhNDc2MmM1ZWFmZmY1Y2Q4ZjBlMjVjNSJ9 END_NESTED_COMMIT
1 parent e5eb1a4 commit 8671525

File tree

10 files changed

+902
-51
lines changed

10 files changed

+902
-51
lines changed

java-eventarc-publishing/google-cloud-eventarc-publishing/src/main/java/com/google/cloud/eventarc/publishing/v1/PublisherClient.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
* PublishChannelConnectionEventsRequest.newBuilder()
6363
* .setChannelConnection("channelConnection-1932021695")
6464
* .addAllEvents(new ArrayList<Any>())
65+
* .addAllTextEvents(new ArrayList<String>())
6566
* .build();
6667
* PublishChannelConnectionEventsResponse response =
6768
* publisherClient.publishChannelConnectionEvents(request);
@@ -131,11 +132,7 @@
131132
* // - It may require correct/in-range values for request initialization.
132133
* // - It may require specifying regional endpoints when creating the service client as shown in
133134
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
134-
* PublisherSettings publisherSettings =
135-
* PublisherSettings.newBuilder()
136-
* .setTransportChannelProvider(
137-
* PublisherSettings.defaultHttpJsonTransportProviderBuilder().build())
138-
* .build();
135+
* PublisherSettings publisherSettings = PublisherSettings.newHttpJsonBuilder().build();
139136
* PublisherClient publisherClient = PublisherClient.create(publisherSettings);
140137
* }</pre>
141138
*
@@ -206,6 +203,7 @@ public PublisherStub getStub() {
206203
* PublishChannelConnectionEventsRequest.newBuilder()
207204
* .setChannelConnection("channelConnection-1932021695")
208205
* .addAllEvents(new ArrayList<Any>())
206+
* .addAllTextEvents(new ArrayList<String>())
209207
* .build();
210208
* PublishChannelConnectionEventsResponse response =
211209
* publisherClient.publishChannelConnectionEvents(request);
@@ -237,6 +235,7 @@ public final PublishChannelConnectionEventsResponse publishChannelConnectionEven
237235
* PublishChannelConnectionEventsRequest.newBuilder()
238236
* .setChannelConnection("channelConnection-1932021695")
239237
* .addAllEvents(new ArrayList<Any>())
238+
* .addAllTextEvents(new ArrayList<String>())
240239
* .build();
241240
* ApiFuture<PublishChannelConnectionEventsResponse> future =
242241
* publisherClient.publishChannelConnectionEventsCallable().futureCall(request);
@@ -268,6 +267,7 @@ public final PublishChannelConnectionEventsResponse publishChannelConnectionEven
268267
* PublishEventsRequest.newBuilder()
269268
* .setChannel("channel738950403")
270269
* .addAllEvents(new ArrayList<Any>())
270+
* .addAllTextEvents(new ArrayList<String>())
271271
* .build();
272272
* PublishEventsResponse response = publisherClient.publishEvents(request);
273273
* }
@@ -297,6 +297,7 @@ public final PublishEventsResponse publishEvents(PublishEventsRequest request) {
297297
* PublishEventsRequest.newBuilder()
298298
* .setChannel("channel738950403")
299299
* .addAllEvents(new ArrayList<Any>())
300+
* .addAllTextEvents(new ArrayList<String>())
300301
* .build();
301302
* ApiFuture<PublishEventsResponse> future =
302303
* publisherClient.publishEventsCallable().futureCall(request);

java-eventarc-publishing/google-cloud-eventarc-publishing/src/main/java/com/google/cloud/eventarc/publishing/v1/package-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
* PublishChannelConnectionEventsRequest.newBuilder()
5757
* .setChannelConnection("channelConnection-1932021695")
5858
* .addAllEvents(new ArrayList<Any>())
59+
* .addAllTextEvents(new ArrayList<String>())
5960
* .build();
6061
* PublishChannelConnectionEventsResponse response =
6162
* publisherClient.publishChannelConnectionEvents(request);

java-eventarc-publishing/google-cloud-eventarc-publishing/src/test/java/com/google/cloud/eventarc/publishing/v1/PublisherClientHttpJsonTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public void publishChannelConnectionEventsTest() throws Exception {
8383
.setChannelConnection(
8484
"projects/project-748/locations/location-748/channelConnections/channelConnection-748")
8585
.addAllEvents(new ArrayList<Any>())
86+
.addAllTextEvents(new ArrayList<String>())
8687
.build();
8788

8889
PublishChannelConnectionEventsResponse actualResponse =
@@ -117,6 +118,7 @@ public void publishChannelConnectionEventsExceptionTest() throws Exception {
117118
.setChannelConnection(
118119
"projects/project-748/locations/location-748/channelConnections/channelConnection-748")
119120
.addAllEvents(new ArrayList<Any>())
121+
.addAllTextEvents(new ArrayList<String>())
120122
.build();
121123
client.publishChannelConnectionEvents(request);
122124
Assert.fail("No exception raised");
@@ -134,6 +136,7 @@ public void publishEventsTest() throws Exception {
134136
PublishEventsRequest.newBuilder()
135137
.setChannel("projects/project-2616/locations/location-2616/channels/channel-2616")
136138
.addAllEvents(new ArrayList<Any>())
139+
.addAllTextEvents(new ArrayList<String>())
137140
.build();
138141

139142
PublishEventsResponse actualResponse = client.publishEvents(request);
@@ -166,6 +169,7 @@ public void publishEventsExceptionTest() throws Exception {
166169
PublishEventsRequest.newBuilder()
167170
.setChannel("projects/project-2616/locations/location-2616/channels/channel-2616")
168171
.addAllEvents(new ArrayList<Any>())
172+
.addAllTextEvents(new ArrayList<String>())
169173
.build();
170174
client.publishEvents(request);
171175
Assert.fail("No exception raised");

java-eventarc-publishing/google-cloud-eventarc-publishing/src/test/java/com/google/cloud/eventarc/publishing/v1/PublisherClientTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public void publishChannelConnectionEventsTest() throws Exception {
8787
PublishChannelConnectionEventsRequest.newBuilder()
8888
.setChannelConnection("channelConnection-1932021695")
8989
.addAllEvents(new ArrayList<Any>())
90+
.addAllTextEvents(new ArrayList<String>())
9091
.build();
9192

9293
PublishChannelConnectionEventsResponse actualResponse =
@@ -100,6 +101,7 @@ public void publishChannelConnectionEventsTest() throws Exception {
100101

101102
Assert.assertEquals(request.getChannelConnection(), actualRequest.getChannelConnection());
102103
Assert.assertEquals(request.getEventsList(), actualRequest.getEventsList());
104+
Assert.assertEquals(request.getTextEventsList(), actualRequest.getTextEventsList());
103105
Assert.assertTrue(
104106
channelProvider.isHeaderSent(
105107
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
@@ -116,6 +118,7 @@ public void publishChannelConnectionEventsExceptionTest() throws Exception {
116118
PublishChannelConnectionEventsRequest.newBuilder()
117119
.setChannelConnection("channelConnection-1932021695")
118120
.addAllEvents(new ArrayList<Any>())
121+
.addAllTextEvents(new ArrayList<String>())
119122
.build();
120123
client.publishChannelConnectionEvents(request);
121124
Assert.fail("No exception raised");
@@ -133,6 +136,7 @@ public void publishEventsTest() throws Exception {
133136
PublishEventsRequest.newBuilder()
134137
.setChannel("channel738950403")
135138
.addAllEvents(new ArrayList<Any>())
139+
.addAllTextEvents(new ArrayList<String>())
136140
.build();
137141

138142
PublishEventsResponse actualResponse = client.publishEvents(request);
@@ -144,6 +148,7 @@ public void publishEventsTest() throws Exception {
144148

145149
Assert.assertEquals(request.getChannel(), actualRequest.getChannel());
146150
Assert.assertEquals(request.getEventsList(), actualRequest.getEventsList());
151+
Assert.assertEquals(request.getTextEventsList(), actualRequest.getTextEventsList());
147152
Assert.assertTrue(
148153
channelProvider.isHeaderSent(
149154
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
@@ -160,6 +165,7 @@ public void publishEventsExceptionTest() throws Exception {
160165
PublishEventsRequest.newBuilder()
161166
.setChannel("channel738950403")
162167
.addAllEvents(new ArrayList<Any>())
168+
.addAllTextEvents(new ArrayList<String>())
163169
.build();
164170
client.publishEvents(request);
165171
Assert.fail("No exception raised");

0 commit comments

Comments
 (0)