Skip to content

Commit

Permalink
feat: Introduce the event publishing using JSON representation of Clo…
Browse files Browse the repository at this point in the history
…udEvents (#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
  • Loading branch information
gcf-owl-bot[bot] authored Nov 8, 2022
1 parent e5eb1a4 commit 8671525
Show file tree
Hide file tree
Showing 10 changed files with 902 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
* PublishChannelConnectionEventsRequest.newBuilder()
* .setChannelConnection("channelConnection-1932021695")
* .addAllEvents(new ArrayList<Any>())
* .addAllTextEvents(new ArrayList<String>())
* .build();
* PublishChannelConnectionEventsResponse response =
* publisherClient.publishChannelConnectionEvents(request);
Expand Down Expand Up @@ -131,11 +132,7 @@
* // - It may require correct/in-range values for request initialization.
* // - It may require specifying regional endpoints when creating the service client as shown in
* // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
* PublisherSettings publisherSettings =
* PublisherSettings.newBuilder()
* .setTransportChannelProvider(
* PublisherSettings.defaultHttpJsonTransportProviderBuilder().build())
* .build();
* PublisherSettings publisherSettings = PublisherSettings.newHttpJsonBuilder().build();
* PublisherClient publisherClient = PublisherClient.create(publisherSettings);
* }</pre>
*
Expand Down Expand Up @@ -206,6 +203,7 @@ public PublisherStub getStub() {
* PublishChannelConnectionEventsRequest.newBuilder()
* .setChannelConnection("channelConnection-1932021695")
* .addAllEvents(new ArrayList<Any>())
* .addAllTextEvents(new ArrayList<String>())
* .build();
* PublishChannelConnectionEventsResponse response =
* publisherClient.publishChannelConnectionEvents(request);
Expand Down Expand Up @@ -237,6 +235,7 @@ public final PublishChannelConnectionEventsResponse publishChannelConnectionEven
* PublishChannelConnectionEventsRequest.newBuilder()
* .setChannelConnection("channelConnection-1932021695")
* .addAllEvents(new ArrayList<Any>())
* .addAllTextEvents(new ArrayList<String>())
* .build();
* ApiFuture<PublishChannelConnectionEventsResponse> future =
* publisherClient.publishChannelConnectionEventsCallable().futureCall(request);
Expand Down Expand Up @@ -268,6 +267,7 @@ public final PublishChannelConnectionEventsResponse publishChannelConnectionEven
* PublishEventsRequest.newBuilder()
* .setChannel("channel738950403")
* .addAllEvents(new ArrayList<Any>())
* .addAllTextEvents(new ArrayList<String>())
* .build();
* PublishEventsResponse response = publisherClient.publishEvents(request);
* }
Expand Down Expand Up @@ -297,6 +297,7 @@ public final PublishEventsResponse publishEvents(PublishEventsRequest request) {
* PublishEventsRequest.newBuilder()
* .setChannel("channel738950403")
* .addAllEvents(new ArrayList<Any>())
* .addAllTextEvents(new ArrayList<String>())
* .build();
* ApiFuture<PublishEventsResponse> future =
* publisherClient.publishEventsCallable().futureCall(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
* PublishChannelConnectionEventsRequest.newBuilder()
* .setChannelConnection("channelConnection-1932021695")
* .addAllEvents(new ArrayList<Any>())
* .addAllTextEvents(new ArrayList<String>())
* .build();
* PublishChannelConnectionEventsResponse response =
* publisherClient.publishChannelConnectionEvents(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public void publishChannelConnectionEventsTest() throws Exception {
.setChannelConnection(
"projects/project-748/locations/location-748/channelConnections/channelConnection-748")
.addAllEvents(new ArrayList<Any>())
.addAllTextEvents(new ArrayList<String>())
.build();

PublishChannelConnectionEventsResponse actualResponse =
Expand Down Expand Up @@ -117,6 +118,7 @@ public void publishChannelConnectionEventsExceptionTest() throws Exception {
.setChannelConnection(
"projects/project-748/locations/location-748/channelConnections/channelConnection-748")
.addAllEvents(new ArrayList<Any>())
.addAllTextEvents(new ArrayList<String>())
.build();
client.publishChannelConnectionEvents(request);
Assert.fail("No exception raised");
Expand All @@ -134,6 +136,7 @@ public void publishEventsTest() throws Exception {
PublishEventsRequest.newBuilder()
.setChannel("projects/project-2616/locations/location-2616/channels/channel-2616")
.addAllEvents(new ArrayList<Any>())
.addAllTextEvents(new ArrayList<String>())
.build();

PublishEventsResponse actualResponse = client.publishEvents(request);
Expand Down Expand Up @@ -166,6 +169,7 @@ public void publishEventsExceptionTest() throws Exception {
PublishEventsRequest.newBuilder()
.setChannel("projects/project-2616/locations/location-2616/channels/channel-2616")
.addAllEvents(new ArrayList<Any>())
.addAllTextEvents(new ArrayList<String>())
.build();
client.publishEvents(request);
Assert.fail("No exception raised");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public void publishChannelConnectionEventsTest() throws Exception {
PublishChannelConnectionEventsRequest.newBuilder()
.setChannelConnection("channelConnection-1932021695")
.addAllEvents(new ArrayList<Any>())
.addAllTextEvents(new ArrayList<String>())
.build();

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

Assert.assertEquals(request.getChannelConnection(), actualRequest.getChannelConnection());
Assert.assertEquals(request.getEventsList(), actualRequest.getEventsList());
Assert.assertEquals(request.getTextEventsList(), actualRequest.getTextEventsList());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
Expand All @@ -116,6 +118,7 @@ public void publishChannelConnectionEventsExceptionTest() throws Exception {
PublishChannelConnectionEventsRequest.newBuilder()
.setChannelConnection("channelConnection-1932021695")
.addAllEvents(new ArrayList<Any>())
.addAllTextEvents(new ArrayList<String>())
.build();
client.publishChannelConnectionEvents(request);
Assert.fail("No exception raised");
Expand All @@ -133,6 +136,7 @@ public void publishEventsTest() throws Exception {
PublishEventsRequest.newBuilder()
.setChannel("channel738950403")
.addAllEvents(new ArrayList<Any>())
.addAllTextEvents(new ArrayList<String>())
.build();

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

Assert.assertEquals(request.getChannel(), actualRequest.getChannel());
Assert.assertEquals(request.getEventsList(), actualRequest.getEventsList());
Assert.assertEquals(request.getTextEventsList(), actualRequest.getTextEventsList());
Assert.assertTrue(
channelProvider.isHeaderSent(
ApiClientHeaderProvider.getDefaultApiClientHeaderKey(),
Expand All @@ -160,6 +165,7 @@ public void publishEventsExceptionTest() throws Exception {
PublishEventsRequest.newBuilder()
.setChannel("channel738950403")
.addAllEvents(new ArrayList<Any>())
.addAllTextEvents(new ArrayList<String>())
.build();
client.publishEvents(request);
Assert.fail("No exception raised");
Expand Down
Loading

0 comments on commit 8671525

Please sign in to comment.