/// <summary>Snippet for GetCall</summary> public void GetCallResourceNames() { // Snippet: GetCall(CallName, CallSettings) // Create client CallsClient callsClient = CallsClient.Create(); // Initialize request argument(s) CallName name = CallName.FromProjectCall("[PROJECT]", "[CALL]"); // Make the request Call response = callsClient.GetCall(name); // End snippet }
/// <summary>Snippet for GetCallAsync</summary> public async Task GetCallResourceNamesAsync() { // Snippet: GetCallAsync(CallName, CallSettings) // Additional: GetCallAsync(CallName, CancellationToken) // Create client CallsClient callsClient = await CallsClient.CreateAsync(); // Initialize request argument(s) CallName name = CallName.FromProjectCall("[PROJECT]", "[CALL]"); // Make the request Call response = await callsClient.GetCallAsync(name); // End snippet }
/// <summary>Snippet for GetCall</summary> public void GetCallRequestObject() { // Snippet: GetCall(GetCallRequest, CallSettings) // Create client CallsClient callsClient = CallsClient.Create(); // Initialize request argument(s) GetCallRequest request = new GetCallRequest { CallName = CallName.FromProjectCall("[PROJECT]", "[CALL]"), }; // Make the request Call response = callsClient.GetCall(request); // End snippet }
/// <summary>Snippet for ListRecordingsAsync</summary> public async Task ListRecordingsRequestObjectAsync() { // Snippet: ListRecordingsAsync(ListRecordingsRequest, CallSettings) // Create client RecordingsClient recordingsClient = await RecordingsClient.CreateAsync(); // Initialize request argument(s) ListRecordingsRequest request = new ListRecordingsRequest { ParentAsCallName = CallName.FromProjectCall("[PROJECT]", "[CALL]"), View = RecordingView.Unspecified, }; // Make the request PagedAsyncEnumerable <ListRecordingsResponse, Recording> response = recordingsClient.ListRecordingsAsync(request); // Iterate over all response items, lazily performing RPCs as required await response.ForEachAsync((Recording item) => { // Do something with each item Console.WriteLine(item); }); // Or iterate over pages (of server-defined size), performing one RPC per page await response.AsRawResponses().ForEachAsync((ListRecordingsResponse page) => { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (Recording item in page) { // Do something with each item Console.WriteLine(item); } }); // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required int pageSize = 10; Page <Recording> singlePage = await response.ReadPageAsync(pageSize); // Do something with the page of items Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); foreach (Recording item in singlePage) { // Do something with each item Console.WriteLine(item); } // Store the pageToken, for when the next page is required. string nextPageToken = singlePage.NextPageToken; // End snippet }
public async stt::Task CreateCallRequestObjectAsync() { moq::Mock <Calls.CallsClient> mockGrpcClient = new moq::Mock <Calls.CallsClient>(moq::MockBehavior.Strict); CreateCallRequest request = new CreateCallRequest { ParentAsProjectName = ProjectName.FromProject("[PROJECT]"), Call = new Call(), }; Call expectedResponse = new Call { CallName = CallName.FromProjectCall("[PROJECT]", "[CALL]"), To = "to03e2b601", From = "fromf8078ad9", IsPrivate = false, Labels = { { "key8a0b6e3c", "value60c16320" }, }, Transport = Call.Types.Transport.Sip, Direction = Call.Types.Direction.Incoming, ErrorCode = "error_code42bd958e", ErrorMessage = "error_messaged73952bd", Price = new gt::Money(), State = Call.Types.State.Busy, CreateTime = new wkt::Timestamp(), StartTime = new wkt::Timestamp(), RingTime = new wkt::Timestamp(), AnswerTime = new wkt::Timestamp(), EndTime = new wkt::Timestamp(), Bridged = true, OriginatingCall = "originating_call9e182b53", CreateMethod = Call.Types.CreateMethod.Api, Options = new Call.Types.ApiCallOptions(), }; mockGrpcClient.Setup(x => x.CreateCallAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Call>(stt::Task.FromResult(expectedResponse), null, null, null, null)); CallsClient client = new CallsClientImpl(mockGrpcClient.Object, null); Call responseCallSettings = await client.CreateCallAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Call responseCancellationToken = await client.CreateCallAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for GetCallAsync</summary> public async Task GetCallRequestObjectAsync() { // Snippet: GetCallAsync(GetCallRequest, CallSettings) // Additional: GetCallAsync(GetCallRequest, CancellationToken) // Create client CallsClient callsClient = await CallsClient.CreateAsync(); // Initialize request argument(s) GetCallRequest request = new GetCallRequest { CallName = CallName.FromProjectCall("[PROJECT]", "[CALL]"), }; // Make the request Call response = await callsClient.GetCallAsync(request); // End snippet }
public void GetCallResourceNames() { moq::Mock <Calls.CallsClient> mockGrpcClient = new moq::Mock <Calls.CallsClient>(moq::MockBehavior.Strict); GetCallRequest request = new GetCallRequest { CallName = CallName.FromProjectCall("[PROJECT]", "[CALL]"), }; Call expectedResponse = new Call { CallName = CallName.FromProjectCall("[PROJECT]", "[CALL]"), To = "to03e2b601", From = "fromf8078ad9", IsPrivate = false, Labels = { { "key8a0b6e3c", "value60c16320" }, }, Transport = Call.Types.Transport.Sip, Direction = Call.Types.Direction.Incoming, ErrorCode = "error_code42bd958e", ErrorMessage = "error_messaged73952bd", Price = new gt::Money(), State = Call.Types.State.Busy, CreateTime = new wkt::Timestamp(), StartTime = new wkt::Timestamp(), RingTime = new wkt::Timestamp(), AnswerTime = new wkt::Timestamp(), EndTime = new wkt::Timestamp(), Bridged = true, OriginatingCall = "originating_call9e182b53", CreateMethod = Call.Types.CreateMethod.Api, Options = new Call.Types.ApiCallOptions(), }; mockGrpcClient.Setup(x => x.GetCall(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); CallsClient client = new CallsClientImpl(mockGrpcClient.Object, null); Call response = client.GetCall(request.CallName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for ListRecordings</summary> public void ListRecordingsResourceNames() { // Snippet: ListRecordings(CallName, string, int?, CallSettings) // Create client RecordingsClient recordingsClient = RecordingsClient.Create(); // Initialize request argument(s) CallName parent = CallName.FromProjectCall("[PROJECT]", "[CALL]"); // Make the request PagedEnumerable <ListRecordingsResponse, Recording> response = recordingsClient.ListRecordings(parent); // Iterate over all response items, lazily performing RPCs as required foreach (Recording item in response) { // Do something with each item Console.WriteLine(item); } // Or iterate over pages (of server-defined size), performing one RPC per page foreach (ListRecordingsResponse page in response.AsRawResponses()) { // Do something with each page of items Console.WriteLine("A page of results:"); foreach (Recording item in page) { // Do something with each item Console.WriteLine(item); } } // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required int pageSize = 10; Page <Recording> singlePage = response.ReadPage(pageSize); // Do something with the page of items Console.WriteLine($"A page of {pageSize} results (unless it's the final page):"); foreach (Recording item in singlePage) { // Do something with each item Console.WriteLine(item); } // Store the pageToken, for when the next page is required. string nextPageToken = singlePage.NextPageToken; // End snippet }