public void TestGetATrigger()
        {
            var client = new DefaultOneNETClient(url, appkey, "");
            var req    = new GetTriggerRequest {
                TriggerID = "20631"
            };
            var rsp = client.Execute(req);

            Assert.IsFalse(rsp.IsError);
            Assert.IsNotNull(rsp.Data);
            Assert.IsNotNull(rsp.Data.Id);
            Console.WriteLine(rsp.Body);
        }
Exemple #2
0
 /// <summary>Snippet for GetTrigger</summary>
 public void GetTriggerRequestObject()
 {
     // Snippet: GetTrigger(GetTriggerRequest, CallSettings)
     // Create client
     EventarcClient eventarcClient = EventarcClient.Create();
     // Initialize request argument(s)
     GetTriggerRequest request = new GetTriggerRequest
     {
         TriggerName = TriggerName.FromProjectLocationTrigger("[PROJECT]", "[LOCATION]", "[TRIGGER]"),
     };
     // Make the request
     Trigger response = eventarcClient.GetTrigger(request);
     // End snippet
 }
Exemple #3
0
        /// <summary>Snippet for GetTriggerAsync</summary>
        public async Task GetTriggerRequestObjectAsync()
        {
            // Snippet: GetTriggerAsync(GetTriggerRequest, CallSettings)
            // Additional: GetTriggerAsync(GetTriggerRequest, CancellationToken)
            // Create client
            EventarcClient eventarcClient = await EventarcClient.CreateAsync();

            // Initialize request argument(s)
            GetTriggerRequest request = new GetTriggerRequest
            {
                TriggerName = TriggerName.FromProjectLocationTrigger("[PROJECT]", "[LOCATION]", "[TRIGGER]"),
            };
            // Make the request
            Trigger response = await eventarcClient.GetTriggerAsync(request);

            // End snippet
        }
        private void HandleOutput(GetTriggerRequest request)
        {
            var waiterConfig = new WaiterConfiguration
            {
                MaxAttempts           = MaxWaitAttempts,
                GetNextDelayInSeconds = (_) => WaitIntervalSeconds
            };

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

            case Default:
                response = client.GetTrigger(request).GetAwaiter().GetResult();
                break;
            }
            WriteOutput(response, response.Trigger);
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            GetTriggerRequest request;

            try
            {
                request = new GetTriggerRequest
                {
                    TriggerId    = TriggerId,
                    OpcRequestId = OpcRequestId
                };

                HandleOutput(request);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Exemple #6
0
        public async stt::Task GetTriggerRequestObjectAsync()
        {
            moq::Mock <Eventarc.EventarcClient> mockGrpcClient = new moq::Mock <Eventarc.EventarcClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetTriggerRequest request = new GetTriggerRequest
            {
                TriggerName = TriggerName.FromProjectLocationTrigger("[PROJECT]", "[LOCATION]", "[TRIGGER]"),
            };
            Trigger expectedResponse = new Trigger
            {
                TriggerName  = TriggerName.FromProjectLocationTrigger("[PROJECT]", "[LOCATION]", "[TRIGGER]"),
                Uid          = "uida2d37198",
                CreateTime   = new wkt::Timestamp(),
                UpdateTime   = new wkt::Timestamp(),
                EventFilters = { new EventFilter(), },
                ServiceAccountAsServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"),
                Destination = new Destination(),
                Transport   = new Transport(),
                Labels      =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Etag = "etage8ad7218",
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Trigger responseCancellationToken = await client.GetTriggerAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Exemple #7
0
        public void GetTriggerResourceNames()
        {
            moq::Mock <Eventarc.EventarcClient> mockGrpcClient = new moq::Mock <Eventarc.EventarcClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetTriggerRequest request = new GetTriggerRequest
            {
                TriggerName = TriggerName.FromProjectLocationTrigger("[PROJECT]", "[LOCATION]", "[TRIGGER]"),
            };
            Trigger expectedResponse = new Trigger
            {
                TriggerName  = TriggerName.FromProjectLocationTrigger("[PROJECT]", "[LOCATION]", "[TRIGGER]"),
                Uid          = "uida2d37198",
                CreateTime   = new wkt::Timestamp(),
                UpdateTime   = new wkt::Timestamp(),
                EventFilters = { new EventFilter(), },
                ServiceAccountAsServiceAccountName = ServiceAccountName.FromProjectServiceAccount("[PROJECT]", "[SERVICE_ACCOUNT]"),
                Destination = new Destination(),
                Transport   = new Transport(),
                Labels      =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Etag = "etage8ad7218",
            };

            mockGrpcClient.Setup(x => x.GetTrigger(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            EventarcClient client   = new EventarcClientImpl(mockGrpcClient.Object, null);
            Trigger        response = client.GetTrigger(request.TriggerName);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Exemple #8
0
 /// <summary>
 /// Gets the trigger.
 /// </summary>
 /// <returns>The trigger.</returns>
 /// <param name="getTriggerRequest">Get trigger request.</param>
 public GetTriggerResponse GetTrigger(GetTriggerRequest getTriggerRequest)
 {
     return(this.DoRequestCommon <GetTriggerResponse>(getTriggerRequest.GenHttpRequest(Config)));
 }
Exemple #9
0
 /// <summary>
 ///  获取触发器详情
 /// </summary>
 /// <param name="request">请求参数信息</param>
 /// <returns>请求结果信息</returns>
 public async Task <GetTriggerResponse> GetTrigger(GetTriggerRequest request)
 {
     return(await new GetTriggerExecutor().Client(this).Execute <GetTriggerResponse, GetTriggerResult, GetTriggerRequest>(request).ConfigureAwait(false));
 }
Exemple #10
0
 /// <summary>
 ///  获取触发器详情
 /// </summary>
 /// <param name="request">请求参数信息</param>
 /// <returns>请求结果信息</returns>
 public GetTriggerResponse GetTrigger(GetTriggerRequest request)
 {
     return(new GetTriggerExecutor().Client(this).Execute <GetTriggerResponse, GetTriggerResult, GetTriggerRequest>(request));
 }