public async stt::Task DeleteEnvironmentResourceNamesAsync() { moq::Mock <Environments.EnvironmentsClient> mockGrpcClient = new moq::Mock <Environments.EnvironmentsClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); DeleteEnvironmentRequest request = new DeleteEnvironmentRequest { EnvironmentName = EnvironmentName.FromProjectLocationAgentEnvironment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeleteEnvironmentAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null)); EnvironmentsClient client = new EnvironmentsClientImpl(mockGrpcClient.Object, null); await client.DeleteEnvironmentAsync(request.EnvironmentName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); await client.DeleteEnvironmentAsync(request.EnvironmentName, st::CancellationToken.None); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for ExportAgentAsync</summary> public async Task ExportAgentRequestObjectAsync() { // Snippet: ExportAgentAsync(ExportAgentRequest, CallSettings) // Additional: ExportAgentAsync(ExportAgentRequest, CancellationToken) // Create client AgentsClient agentsClient = await AgentsClient.CreateAsync(); // Initialize request argument(s) ExportAgentRequest request = new ExportAgentRequest { AgentName = AgentName.FromProjectLocationAgent("[PROJECT]", "[LOCATION]", "[AGENT]"), AgentUri = "", EnvironmentAsEnvironmentName = EnvironmentName.FromProjectLocationAgentEnvironment("[PROJECT]", "[LOCATION]", "[AGENT]", "[ENVIRONMENT]"), }; // Make the request Operation <ExportAgentResponse, Struct> response = await agentsClient.ExportAgentAsync(request); // Poll until the returned long-running operation is complete Operation <ExportAgentResponse, Struct> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result ExportAgentResponse result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <ExportAgentResponse, Struct> retrievedResponse = await agentsClient.PollOnceExportAgentAsync(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result ExportAgentResponse retrievedResult = retrievedResponse.Result; } // End snippet }