Skip to content

Commit

Permalink
feat: Add publishing methods for channel resources
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 442858558

Source-Link: googleapis/googleapis@726dac2

Source-Link: googleapis/googleapis-gen@b2ecfcf
Copy-Tag: eyJwIjoiYXBpcy9Hb29nbGUuQ2xvdWQuRXZlbnRhcmMuUHVibGlzaGluZy5WMS8uT3dsQm90LnlhbWwiLCJoIjoiYjJlY2ZjZjI1MjQzNmViZTIxMzc2NjRlYTQxY2RjZDMzZDM2ZTJhZiJ9
  • Loading branch information
gcf-owl-bot[bot] authored and jskeet committed Apr 20, 2022
1 parent bfb3a24 commit b5ef156
Show file tree
Hide file tree
Showing 9 changed files with 770 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Generated code. DO NOT EDIT!

namespace Google.Cloud.Eventarc.Publishing.V1.Snippets
{
// [START eventarcpublishing_v1_generated_Publisher_PublishEvents_async]
using Google.Cloud.Eventarc.Publishing.V1;
using Google.Protobuf.WellKnownTypes;
using System.Threading.Tasks;

public sealed partial class GeneratedPublisherClientSnippets
{
/// <summary>Snippet for PublishEventsAsync</summary>
/// <remarks>
/// This snippet has been automatically generated for illustrative purposes only.
/// It may require modifications to work in your environment.
/// </remarks>
public async Task PublishEventsRequestObjectAsync()
{
// Create client
PublisherClient publisherClient = await PublisherClient.CreateAsync();
// Initialize request argument(s)
PublishEventsRequest request = new PublishEventsRequest
{
Channel = "",
Events = { new Any(), },
};
// Make the request
PublishEventsResponse response = await publisherClient.PublishEventsAsync(request);
}
}
// [END eventarcpublishing_v1_generated_Publisher_PublishEvents_async]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// Generated code. DO NOT EDIT!

namespace Google.Cloud.Eventarc.Publishing.V1.Snippets
{
// [START eventarcpublishing_v1_generated_Publisher_PublishEvents_sync]
using Google.Cloud.Eventarc.Publishing.V1;
using Google.Protobuf.WellKnownTypes;

public sealed partial class GeneratedPublisherClientSnippets
{
/// <summary>Snippet for PublishEvents</summary>
/// <remarks>
/// This snippet has been automatically generated for illustrative purposes only.
/// It may require modifications to work in your environment.
/// </remarks>
public void PublishEventsRequestObject()
{
// Create client
PublisherClient publisherClient = PublisherClient.Create();
// Initialize request argument(s)
PublishEventsRequest request = new PublishEventsRequest
{
Channel = "",
Events = { new Any(), },
};
// Make the request
PublishEventsResponse response = publisherClient.PublishEvents(request);
}
}
// [END eventarcpublishing_v1_generated_Publisher_PublishEvents_sync]
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,59 @@
},
"canonical": true,
"origin": "API_DEFINITION"
},
{
"regionTag": "eventarcpublishing_v1_generated_Publisher_PublishEvents_sync",
"title": "PublishEventsRequestObject",
"description": "Snippet for PublishEvents",
"file": "PublisherClient.PublishEventsRequestObjectSnippet.g.cs",
"language": "C_SHARP",
"clientMethod": {
"shortName": "PublishEvents",
"fullName": "Google.Cloud.Eventarc.Publishing.V1.PublisherClient.PublishEvents",
"resultType": "Google.Cloud.Eventarc.Publishing.V1.PublishEventsResponse",
"client": {
"shortName": "PublisherClient",
"fullName": "Google.Cloud.Eventarc.Publishing.V1.PublisherClient"
},
"method": {
"shortName": "PublishEvents",
"fullName": "google.cloud.eventarc.publishing.v1.Publisher.PublishEvents",
"service": {
"shortName": "Publisher",
"fullName": "google.cloud.eventarc.publishing.v1.Publisher"
}
}
},
"canonical": true,
"origin": "API_DEFINITION"
},
{
"regionTag": "eventarcpublishing_v1_generated_Publisher_PublishEvents_async",
"title": "PublishEventsRequestObjectAsync",
"description": "Snippet for PublishEventsAsync",
"file": "PublisherClient.PublishEventsRequestObjectAsyncSnippet.g.cs",
"language": "C_SHARP",
"clientMethod": {
"shortName": "PublishEventsAsync",
"fullName": "Google.Cloud.Eventarc.Publishing.V1.PublisherClient.PublishEventsAsync",
"async": true,
"resultType": "System.Threading.Tasks.Task<Google.Cloud.Eventarc.Publishing.V1.PublishEventsResponse>",
"client": {
"shortName": "PublisherClient",
"fullName": "Google.Cloud.Eventarc.Publishing.V1.PublisherClient"
},
"method": {
"shortName": "PublishEvents",
"fullName": "google.cloud.eventarc.publishing.v1.Publisher.PublishEvents",
"service": {
"shortName": "Publisher",
"fullName": "google.cloud.eventarc.publishing.v1.Publisher"
}
}
},
"canonical": true,
"origin": "API_DEFINITION"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,40 @@ public async Task PublishChannelConnectionEventsRequestObjectAsync()
PublishChannelConnectionEventsResponse response = await publisherClient.PublishChannelConnectionEventsAsync(request);
// End snippet
}

/// <summary>Snippet for PublishEvents</summary>
public void PublishEventsRequestObject()
{
// Snippet: PublishEvents(PublishEventsRequest, CallSettings)
// Create client
PublisherClient publisherClient = PublisherClient.Create();
// Initialize request argument(s)
PublishEventsRequest request = new PublishEventsRequest
{
Channel = "",
Events = { new Any(), },
};
// Make the request
PublishEventsResponse response = publisherClient.PublishEvents(request);
// End snippet
}

/// <summary>Snippet for PublishEventsAsync</summary>
public async Task PublishEventsRequestObjectAsync()
{
// Snippet: PublishEventsAsync(PublishEventsRequest, CallSettings)
// Additional: PublishEventsAsync(PublishEventsRequest, CancellationToken)
// Create client
PublisherClient publisherClient = await PublisherClient.CreateAsync();
// Initialize request argument(s)
PublishEventsRequest request = new PublishEventsRequest
{
Channel = "",
Events = { new Any(), },
};
// Make the request
PublishEventsResponse response = await publisherClient.PublishEventsAsync(request);
// End snippet
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,41 @@ public void PublishChannelConnectionEventsRequestObject()
xunit::Assert.Same(expectedResponse, responseCancellationToken);
mockGrpcClient.VerifyAll();
}

[xunit::FactAttribute]
public void PublishEventsRequestObject()
{
moq::Mock<Publisher.PublisherClient> mockGrpcClient = new moq::Mock<Publisher.PublisherClient>(moq::MockBehavior.Strict);
PublishEventsRequest request = new PublishEventsRequest
{
Channel = "channeledd285c4",
Events = { new wkt::Any(), },
};
PublishEventsResponse expectedResponse = new PublishEventsResponse { };
mockGrpcClient.Setup(x => x.PublishEvents(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(expectedResponse);
PublisherClient client = new PublisherClientImpl(mockGrpcClient.Object, null);
PublishEventsResponse response = client.PublishEvents(request);
xunit::Assert.Same(expectedResponse, response);
mockGrpcClient.VerifyAll();
}

[xunit::FactAttribute]
public async stt::Task PublishEventsRequestObjectAsync()
{
moq::Mock<Publisher.PublisherClient> mockGrpcClient = new moq::Mock<Publisher.PublisherClient>(moq::MockBehavior.Strict);
PublishEventsRequest request = new PublishEventsRequest
{
Channel = "channeledd285c4",
Events = { new wkt::Any(), },
};
PublishEventsResponse expectedResponse = new PublishEventsResponse { };
mockGrpcClient.Setup(x => x.PublishEventsAsync(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall<PublishEventsResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
PublisherClient client = new PublisherClientImpl(mockGrpcClient.Object, null);
PublishEventsResponse responseCallSettings = await client.PublishEventsAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));
xunit::Assert.Same(expectedResponse, responseCallSettings);
PublishEventsResponse responseCancellationToken = await client.PublishEventsAsync(request, st::CancellationToken.None);
xunit::Assert.Same(expectedResponse, responseCancellationToken);
mockGrpcClient.VerifyAll();
}
}
}
Loading

0 comments on commit b5ef156

Please sign in to comment.