/// <summary>Snippet for Get</summary> public void GetRequestObject() { // Snippet: Get(GetBackendServiceRequest, CallSettings) // Create client BackendServicesClient backendServicesClient = BackendServicesClient.Create(); // Initialize request argument(s) GetBackendServiceRequest request = new GetBackendServiceRequest { Project = "", BackendService = "", }; // Make the request BackendService response = backendServicesClient.Get(request); // End snippet }
/// <summary>Snippet for GetAsync</summary> public async Task GetRequestObjectAsync() { // Snippet: GetAsync(GetBackendServiceRequest, CallSettings) // Additional: GetAsync(GetBackendServiceRequest, CancellationToken) // Create client BackendServicesClient backendServicesClient = await BackendServicesClient.CreateAsync(); // Initialize request argument(s) GetBackendServiceRequest request = new GetBackendServiceRequest { Project = "", BackendService = "", }; // Make the request BackendService response = await backendServicesClient.GetAsync(request); // End snippet }
public async stt::Task GetRequestObjectAsync() { moq::Mock <BackendServices.BackendServicesClient> mockGrpcClient = new moq::Mock <BackendServices.BackendServicesClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClientForGlobalOperations()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetBackendServiceRequest request = new GetBackendServiceRequest { Project = "projectaa6ff846", BackendService = "backend_serviceed490d45", }; BackendService expectedResponse = new BackendService { Id = 11672635353343658936UL, Iap = new BackendServiceIAP(), ConsistentHash = new ConsistentHashLoadBalancerSettings(), Kind = "kindf7aa39d9", Name = "name1c9368b0", Port = -78310000, CustomRequestHeaders = { "custom_request_headers3532c035", }, CreationTimestamp = "creation_timestamp235e59a1", PortName = "port_namebaaa4cd4", MaxStreamDuration = new Duration(), TimeoutSec = -1529270667, Protocol = "protocola08b7881", FailoverPolicy = new BackendServiceFailoverPolicy(), LocalityLbPolicy = "locality_lb_policyc8722098", Region = "regionedb20d96", SecurityPolicy = "security_policy76596315", CdnPolicy = new BackendServiceCdnPolicy(), Network = "networkd22ce091", Fingerprint = "fingerprint009e6052", EnableCDN = false, LogConfig = new BackendServiceLogConfig(), OutlierDetection = new OutlierDetection(), LoadBalancingScheme = "load_balancing_scheme21346104", AffinityCookieTtlSec = -328985636, CustomResponseHeaders = { "custom_response_headersda5d431e", }, CircuitBreakers = new CircuitBreakers(), Description = "description2cf9da67", HealthChecks = { "health_checksedb1f3f8", }, Subsetting = new Subsetting(), SelfLink = "self_link7e87f12d", ConnectionDraining = new ConnectionDraining(), SessionAffinity = "session_affinitye702dadf", SecuritySettings = new SecuritySettings(), Backends = { new Backend(), }, }; mockGrpcClient.Setup(x => x.GetAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <BackendService>(stt::Task.FromResult(expectedResponse), null, null, null, null)); BackendServicesClient client = new BackendServicesClientImpl(mockGrpcClient.Object, null); BackendService responseCallSettings = await client.GetAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); BackendService responseCancellationToken = await client.GetAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }