public async stt::Task GetHealthAsync() { moq::Mock <TargetPools.TargetPoolsClient> mockGrpcClient = new moq::Mock <TargetPools.TargetPoolsClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetHealthTargetPoolRequest request = new GetHealthTargetPoolRequest { TargetPool = "target_pool65e437ac", Region = "regionedb20d96", Project = "projectaa6ff846", InstanceReferenceResource = new InstanceReference(), }; TargetPoolInstanceHealth expectedResponse = new TargetPoolInstanceHealth { Kind = "kindf7aa39d9", HealthStatus = { new HealthStatus(), }, }; mockGrpcClient.Setup(x => x.GetHealthAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <TargetPoolInstanceHealth>(stt::Task.FromResult(expectedResponse), null, null, null, null)); TargetPoolsClient client = new TargetPoolsClientImpl(mockGrpcClient.Object, null); TargetPoolInstanceHealth responseCallSettings = await client.GetHealthAsync(request.Project, request.Region, request.TargetPool, request.InstanceReferenceResource, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); TargetPoolInstanceHealth responseCancellationToken = await client.GetHealthAsync(request.Project, request.Region, request.TargetPool, request.InstanceReferenceResource, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetHealth() { moq::Mock <TargetPools.TargetPoolsClient> mockGrpcClient = new moq::Mock <TargetPools.TargetPoolsClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetHealthTargetPoolRequest request = new GetHealthTargetPoolRequest { TargetPool = "target_pool65e437ac", Region = "regionedb20d96", Project = "projectaa6ff846", InstanceReferenceResource = new InstanceReference(), }; TargetPoolInstanceHealth expectedResponse = new TargetPoolInstanceHealth { Kind = "kindf7aa39d9", HealthStatus = { new HealthStatus(), }, }; mockGrpcClient.Setup(x => x.GetHealth(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); TargetPoolsClient client = new TargetPoolsClientImpl(mockGrpcClient.Object, null); TargetPoolInstanceHealth response = client.GetHealth(request.Project, request.Region, request.TargetPool, request.InstanceReferenceResource); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
/// <summary>Snippet for GetHealth</summary> public void GetHealth() { // Snippet: GetHealth(string, string, string, InstanceReference, CallSettings) // Create client TargetPoolsClient targetPoolsClient = TargetPoolsClient.Create(); // Initialize request argument(s) string project = ""; string region = ""; string targetPool = ""; InstanceReference instanceReferenceResource = new InstanceReference(); // Make the request TargetPoolInstanceHealth response = targetPoolsClient.GetHealth(project, region, targetPool, instanceReferenceResource); // End snippet }
/// <summary>Snippet for GetHealthAsync</summary> public async Task GetHealthAsync() { // Snippet: GetHealthAsync(string, string, string, InstanceReference, CallSettings) // Additional: GetHealthAsync(string, string, string, InstanceReference, CancellationToken) // Create client TargetPoolsClient targetPoolsClient = await TargetPoolsClient.CreateAsync(); // Initialize request argument(s) string project = ""; string region = ""; string targetPool = ""; InstanceReference instanceReferenceResource = new InstanceReference(); // Make the request TargetPoolInstanceHealth response = await targetPoolsClient.GetHealthAsync(project, region, targetPool, instanceReferenceResource); // End snippet }
/// <summary>Snippet for GetHealth</summary> public void GetHealthRequestObject() { // Snippet: GetHealth(GetHealthTargetPoolRequest, CallSettings) // Create client TargetPoolsClient targetPoolsClient = TargetPoolsClient.Create(); // Initialize request argument(s) GetHealthTargetPoolRequest request = new GetHealthTargetPoolRequest { TargetPool = "", Region = "", Project = "", InstanceReferenceResource = new InstanceReference(), }; // Make the request TargetPoolInstanceHealth response = targetPoolsClient.GetHealth(request); // End snippet }
/// <summary>Snippet for GetHealthAsync</summary> public async Task GetHealthRequestObjectAsync() { // Snippet: GetHealthAsync(GetHealthTargetPoolRequest, CallSettings) // Additional: GetHealthAsync(GetHealthTargetPoolRequest, CancellationToken) // Create client TargetPoolsClient targetPoolsClient = await TargetPoolsClient.CreateAsync(); // Initialize request argument(s) GetHealthTargetPoolRequest request = new GetHealthTargetPoolRequest { TargetPool = "", Region = "", Project = "", InstanceReferenceResource = new InstanceReference(), }; // Make the request TargetPoolInstanceHealth response = await targetPoolsClient.GetHealthAsync(request); // End snippet }
private IEnumerable <HealthStatus> GetPoolHealth(IEnumerable <TargetPool> pools) { foreach (TargetPool targetPool in pools) { foreach (string instanceUrl in targetPool.Instances ?? Enumerable.Empty <string>()) { InstanceReference body = new InstanceReference { Instance = instanceUrl }; string project = GetProjectNameFromUri(targetPool.SelfLink); string region = GetRegionNameFromUri(targetPool.Region); TargetPoolsResource.GetHealthRequest request = Service.TargetPools.GetHealth(body, project, region, targetPool.Name); TargetPoolInstanceHealth response = request.Execute(); var statuses = response.HealthStatus ?? Enumerable.Empty <HealthStatus>(); foreach (HealthStatus healthStatus in statuses) { yield return(healthStatus); } } } }