public async Task GetGlossaryAsync()
        {
            Mock <TranslationService.TranslationServiceClient> mockGrpcClient = new Mock <TranslationService.TranslationServiceClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            GetGlossaryRequest expectedRequest = new GetGlossaryRequest
            {
                GlossaryName = new GlossaryName("[PROJECT]", "[LOCATION]", "[GLOSSARY]"),
            };
            Glossary expectedResponse = new Glossary
            {
                GlossaryName = new GlossaryName("[PROJECT]", "[LOCATION]", "[GLOSSARY]"),
                EntryCount   = 811131134,
            };

            mockGrpcClient.Setup(x => x.GetGlossaryAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Glossary>(Task.FromResult(expectedResponse), null, null, null, null));
            TranslationServiceClient client = new TranslationServiceClientImpl(mockGrpcClient.Object, null);
            GlossaryName             name   = new GlossaryName("[PROJECT]", "[LOCATION]", "[GLOSSARY]");
            Glossary response = await client.GetGlossaryAsync(name);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void GetGlossary()
        {
            Mock <TranslationService.TranslationServiceClient> mockGrpcClient = new Mock <TranslationService.TranslationServiceClient>(MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient())
            .Returns(new Mock <Operations.OperationsClient>().Object);
            GetGlossaryRequest expectedRequest = new GetGlossaryRequest
            {
                Name = new GlossaryName("[PROJECT]", "[LOCATION]", "[GLOSSARY]").ToString(),
            };
            Glossary expectedResponse = new Glossary
            {
                Name       = "name2-1052831874",
                EntryCount = 811131134,
            };

            mockGrpcClient.Setup(x => x.GetGlossary(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            TranslationServiceClient client = new TranslationServiceClientImpl(mockGrpcClient.Object, null);
            string   formattedName          = new GlossaryName("[PROJECT]", "[LOCATION]", "[GLOSSARY]").ToString();
            Glossary response = client.GetGlossary(formattedName);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a waiter using the provided configuration.
        /// </summary>
        /// <param name="request">Request to send.</param>
        /// <param name="config">Wait Configuration</param>
        /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param>
        /// <returns>a new Oci.common.Waiter instance</returns>
        public Waiter <GetGlossaryRequest, GetGlossaryResponse> ForGlossary(GetGlossaryRequest request, WaiterConfiguration config, params LifecycleState[] targetStates)
        {
            var agent = new WaiterAgent <GetGlossaryRequest, GetGlossaryResponse>(
                request,
                request => client.GetGlossary(request),
                response => targetStates.Contains(response.Glossary.LifecycleState.Value),
                targetStates.Contains(LifecycleState.Deleted)
                );

            return(new Waiter <GetGlossaryRequest, GetGlossaryResponse>(config, agent));
        }
 /// <summary>Snippet for GetGlossary</summary>
 public void GetGlossary_RequestObject()
 {
     // Snippet: GetGlossary(GetGlossaryRequest,CallSettings)
     // Create client
     TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
     // Initialize request argument(s)
     GetGlossaryRequest request = new GetGlossaryRequest
     {
         GlossaryName = new GlossaryName("[PROJECT]", "[LOCATION]", "[GLOSSARY]"),
     };
     // Make the request
     Glossary response = translationServiceClient.GetGlossary(request);
     // End snippet
 }
Esempio n. 5
0
        /// <summary>
        /// Retrieves a glossary.
        /// </summary>
        /// <param name="projectId">Your Google Cloud Project ID.</param>
        /// <param name="glossaryId">Glossary ID.</param>
        public static void GetGlossarySample(string projectId  = "[Google Cloud Project ID]",
                                             string glossaryId = "[YOUR_GLOSSARY_ID]")
        {
            TranslationServiceClient translationServiceClient = TranslationServiceClient.Create();
            GetGlossaryRequest       request = new GetGlossaryRequest
            {
                GlossaryName = new GlossaryName(projectId, "us-central1", glossaryId),
            };
            Glossary response = translationServiceClient.GetGlossary(request);

            Console.WriteLine($"Glossary name: {response.Name}");
            Console.WriteLine($"Entry count: {response.EntryCount}");
            Console.WriteLine($"Input URI: {response.InputConfig.GcsSource.InputUri}");
        }
        /// <summary>Snippet for GetGlossaryAsync</summary>
        public async Task GetGlossaryAsync_RequestObject()
        {
            // Snippet: GetGlossaryAsync(GetGlossaryRequest,CallSettings)
            // Additional: GetGlossaryAsync(GetGlossaryRequest,CancellationToken)
            // Create client
            TranslationServiceClient translationServiceClient = await TranslationServiceClient.CreateAsync();

            // Initialize request argument(s)
            GetGlossaryRequest request = new GetGlossaryRequest
            {
                GlossaryName = new GlossaryName("[PROJECT]", "[LOCATION]", "[GLOSSARY]"),
            };
            // Make the request
            Glossary response = await translationServiceClient.GetGlossaryAsync(request);

            // End snippet
        }
Esempio n. 7
0
        private void HandleOutput(GetGlossaryRequest request)
        {
            var waiterConfig = new WaiterConfiguration
            {
                MaxAttempts           = MaxWaitAttempts,
                GetNextDelayInSeconds = (_) => WaitIntervalSeconds
            };

            switch (ParameterSetName)
            {
            case LifecycleStateParamSet:
                response = client.Waiters.ForGlossary(request, waiterConfig, WaitForLifecycleState).Execute();
                break;

            case Default:
                response = client.GetGlossary(request).GetAwaiter().GetResult();
                break;
            }
            WriteOutput(response, response.Glossary);
        }
Esempio n. 8
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            GetGlossaryRequest request;

            try
            {
                request = new GetGlossaryRequest
                {
                    CatalogId    = CatalogId,
                    GlossaryKey  = GlossaryKey,
                    Fields       = Fields,
                    OpcRequestId = OpcRequestId
                };

                HandleOutput(request);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Esempio n. 9
0
 /// <summary>
 /// Creates a waiter using default wait configuration.
 /// </summary>
 /// <param name="request">Request to send.</param>
 /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param>
 /// <returns>a new Oci.common.Waiter instance</returns>
 public Waiter <GetGlossaryRequest, GetGlossaryResponse> ForGlossary(GetGlossaryRequest request, params LifecycleState[] targetStates)
 {
     return(this.ForGlossary(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates));
 }