Exemplo n.º 1
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            UpdateAgentRequest request;

            try
            {
                request = new UpdateAgentRequest
                {
                    AgentId            = AgentId,
                    UpdateAgentDetails = UpdateAgentDetails,
                    OpcRequestId       = OpcRequestId,
                    OpcRetryToken      = OpcRetryToken,
                    IfMatch            = IfMatch
                };

                response = client.UpdateAgent(request).GetAwaiter().GetResult();
                WriteOutput(response, response.Agent);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
        public async stt::Task UpdateAgentAsync()
        {
            moq::Mock <Agents.AgentsClient> mockGrpcClient = new moq::Mock <Agents.AgentsClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            UpdateAgentRequest request = new UpdateAgentRequest
            {
                Agent      = new Agent(),
                UpdateMask = new wkt::FieldMask(),
            };
            Agent expectedResponse = new Agent
            {
                AgentName                = AgentName.FromProjectLocationAgent("[PROJECT]", "[LOCATION]", "[AGENT]"),
                DisplayName              = "display_name137f65c2",
                DefaultLanguageCode      = "default_language_codee612e130",
                TimeZone                 = "time_zone73f23b20",
                Description              = "description2cf9da67",
                AvatarUri                = "avatar_urie1767db7",
                SpeechToTextSettings     = new SpeechToTextSettings(),
                StartFlowAsFlowName      = FlowName.FromProjectLocationAgentFlow("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]"),
                EnableStackdriverLogging = false,
                EnableSpellCorrection    = true,
            };

            mockGrpcClient.Setup(x => x.UpdateAgentAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Agent>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            AgentsClient client = new AgentsClientImpl(mockGrpcClient.Object, null);
            Agent        responseCallSettings = await client.UpdateAgentAsync(request.Agent, request.UpdateMask, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Agent responseCancellationToken = await client.UpdateAgentAsync(request.Agent, request.UpdateMask, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
 /// <summary>Snippet for UpdateAgent</summary>
 public void UpdateAgentRequestObject()
 {
     // Snippet: UpdateAgent(UpdateAgentRequest, CallSettings)
     // Create client
     AgentsClient agentsClient = AgentsClient.Create();
     // Initialize request argument(s)
     UpdateAgentRequest request = new UpdateAgentRequest
     {
         Agent      = new Agent(),
         UpdateMask = new FieldMask(),
     };
     // Make the request
     Agent response = agentsClient.UpdateAgent(request);
     // End snippet
 }
        /// <summary>Snippet for UpdateAgentAsync</summary>
        public async Task UpdateAgentRequestObjectAsync()
        {
            // Snippet: UpdateAgentAsync(UpdateAgentRequest, CallSettings)
            // Additional: UpdateAgentAsync(UpdateAgentRequest, CancellationToken)
            // Create client
            AgentsClient agentsClient = await AgentsClient.CreateAsync();

            // Initialize request argument(s)
            UpdateAgentRequest request = new UpdateAgentRequest
            {
                Agent      = new Agent(),
                UpdateMask = new FieldMask(),
            };
            // Make the request
            Agent response = await agentsClient.UpdateAgentAsync(request);

            // End snippet
        }