/// <summary>Snippet for Get</summary> public void GetRequestObject() { // Snippet: Get(GetForwardingRuleRequest, CallSettings) // Create client ForwardingRulesClient forwardingRulesClient = ForwardingRulesClient.Create(); // Initialize request argument(s) GetForwardingRuleRequest request = new GetForwardingRuleRequest { Region = "", Project = "", ForwardingRule = "", }; // Make the request ForwardingRule response = forwardingRulesClient.Get(request); // End snippet }
/// <summary>Snippet for GetAsync</summary> public async Task GetRequestObjectAsync() { // Snippet: GetAsync(GetForwardingRuleRequest, CallSettings) // Additional: GetAsync(GetForwardingRuleRequest, CancellationToken) // Create client ForwardingRulesClient forwardingRulesClient = await ForwardingRulesClient.CreateAsync(); // Initialize request argument(s) GetForwardingRuleRequest request = new GetForwardingRuleRequest { Region = "", Project = "", ForwardingRule = "", }; // Make the request ForwardingRule response = await forwardingRulesClient.GetAsync(request); // End snippet }
public async stt::Task GetRequestObjectAsync() { moq::Mock <ForwardingRules.ForwardingRulesClient> mockGrpcClient = new moq::Mock <ForwardingRules.ForwardingRulesClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetForwardingRuleRequest request = new GetForwardingRuleRequest { Region = "regionedb20d96", Project = "projectaa6ff846", ForwardingRule = "forwarding_rule51d5478e", }; ForwardingRule expectedResponse = new ForwardingRule { Id = 11672635353343658936UL, Kind = "kindf7aa39d9", Name = "name1c9368b0", CreationTimestamp = "creation_timestamp235e59a1", IPAddress = "I_p_addressf1537179", Ports = { "ports9860f047", }, IsMirroringCollector = false, Region = "regionedb20d96", LabelFingerprint = "label_fingerprint06ccff3a", PscConnectionStatus = ForwardingRule.Types.PscConnectionStatus.UndefinedPscConnectionStatus, Target = "targetaefbae42", PortRange = "port_ranged4420f7d", ServiceDirectoryRegistrations = { new ForwardingRuleServiceDirectoryRegistration(), }, Network = "networkd22ce091", Fingerprint = "fingerprint009e6052", PscConnectionId = 1768355415909345202UL, IpVersion = ForwardingRule.Types.IpVersion.UndefinedIpVersion, BackendService = "backend_serviceed490d45", Subnetwork = "subnetworkf55bf572", ServiceName = "service_named5df05d5", LoadBalancingScheme = ForwardingRule.Types.LoadBalancingScheme.UndefinedLoadBalancingScheme, ServiceLabel = "service_label5f95d0c0", Description = "description2cf9da67", AllPorts = false, SelfLink = "self_link7e87f12d", MetadataFilters = { new MetadataFilter(), }, IPProtocol = ForwardingRule.Types.IPProtocol.Udp, AllowGlobalAccess = false, Labels = { { "key8a0b6e3c", "value60c16320" }, }, NetworkTier = ForwardingRule.Types.NetworkTier.Standard, }; mockGrpcClient.Setup(x => x.GetAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ForwardingRule>(stt::Task.FromResult(expectedResponse), null, null, null, null)); ForwardingRulesClient client = new ForwardingRulesClientImpl(mockGrpcClient.Object, null); ForwardingRule responseCallSettings = await client.GetAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); ForwardingRule responseCancellationToken = await client.GetAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetRequestObject() { moq::Mock <ForwardingRules.ForwardingRulesClient> mockGrpcClient = new moq::Mock <ForwardingRules.ForwardingRulesClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClientForRegionOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetForwardingRuleRequest request = new GetForwardingRuleRequest { Region = "regionedb20d96", Project = "projectaa6ff846", ForwardingRule = "forwarding_rule51d5478e", }; ForwardingRule expectedResponse = new ForwardingRule { Id = 11672635353343658936UL, Kind = "kindf7aa39d9", Name = "name1c9368b0", CreationTimestamp = "creation_timestamp235e59a1", IPAddress = "I_p_addressf1537179", Ports = { "ports9860f047", }, IsMirroringCollector = false, Region = "regionedb20d96", LabelFingerprint = "label_fingerprint06ccff3a", PscConnectionStatus = "psc_connection_status437a3762", Target = "targetaefbae42", PortRange = "port_ranged4420f7d", ServiceDirectoryRegistrations = { new ForwardingRuleServiceDirectoryRegistration(), }, Network = "networkd22ce091", Fingerprint = "fingerprint009e6052", PscConnectionId = 1768355415909345202UL, IpVersion = "ip_versionde91b460", BackendService = "backend_serviceed490d45", Subnetwork = "subnetworkf55bf572", ServiceName = "service_named5df05d5", LoadBalancingScheme = "load_balancing_scheme21346104", ServiceLabel = "service_label5f95d0c0", Description = "description2cf9da67", AllPorts = false, SelfLink = "self_link7e87f12d", MetadataFilters = { new MetadataFilter(), }, IPProtocol = "I_p_protocold854c15f", AllowGlobalAccess = false, Labels = { { "key8a0b6e3c", "value60c16320" }, }, NetworkTier = "network_tiere6fea951", }; mockGrpcClient.Setup(x => x.Get(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); ForwardingRulesClient client = new ForwardingRulesClientImpl(mockGrpcClient.Object, null); ForwardingRule response = client.Get(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }