Skip to content

Commit ae2f0fe

Browse files
feat: [eventarcpublishing] Introduce the event publishing using JSON representation of CloudEvents (#8730)
* feat: Introduce the event publishing using JSON representation of CloudEvents 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: googleapis/googleapis@079ef84 Source-Link: https://github.com/googleapis/googleapis-gen/commit/dd62dfc174abb25bf2e50a2a54651da70daed781 Copy-Tag: eyJwIjoiamF2YS1ldmVudGFyYy1wdWJsaXNoaW5nLy5Pd2xCb3QueWFtbCIsImgiOiJkZDYyZGZjMTc0YWJiMjViZjJlNTBhMmE1NDY1MWRhNzBkYWVkNzgxIn0= * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent ba1a887 commit ae2f0fe

File tree

10 files changed

+901
-46
lines changed

10 files changed

+901
-46
lines changed

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

Lines changed: 5 additions & 0 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);
@@ -202,6 +203,7 @@ public PublisherStub getStub() {
202203
* PublishChannelConnectionEventsRequest.newBuilder()
203204
* .setChannelConnection("channelConnection-1932021695")
204205
* .addAllEvents(new ArrayList<Any>())
206+
* .addAllTextEvents(new ArrayList<String>())
205207
* .build();
206208
* PublishChannelConnectionEventsResponse response =
207209
* publisherClient.publishChannelConnectionEvents(request);
@@ -233,6 +235,7 @@ public final PublishChannelConnectionEventsResponse publishChannelConnectionEven
233235
* PublishChannelConnectionEventsRequest.newBuilder()
234236
* .setChannelConnection("channelConnection-1932021695")
235237
* .addAllEvents(new ArrayList<Any>())
238+
* .addAllTextEvents(new ArrayList<String>())
236239
* .build();
237240
* ApiFuture<PublishChannelConnectionEventsResponse> future =
238241
* publisherClient.publishChannelConnectionEventsCallable().futureCall(request);
@@ -264,6 +267,7 @@ public final PublishChannelConnectionEventsResponse publishChannelConnectionEven
264267
* PublishEventsRequest.newBuilder()
265268
* .setChannel("channel738950403")
266269
* .addAllEvents(new ArrayList<Any>())
270+
* .addAllTextEvents(new ArrayList<String>())
267271
* .build();
268272
* PublishEventsResponse response = publisherClient.publishEvents(request);
269273
* }
@@ -293,6 +297,7 @@ public final PublishEventsResponse publishEvents(PublishEventsRequest request) {
293297
* PublishEventsRequest.newBuilder()
294298
* .setChannel("channel738950403")
295299
* .addAllEvents(new ArrayList<Any>())
300+
* .addAllTextEvents(new ArrayList<String>())
296301
* .build();
297302
* ApiFuture<PublishEventsResponse> future =
298303
* 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)