Ejemplo n.º 1
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 <GetDetectorRequest, GetDetectorResponse> ForDetector(GetDetectorRequest request, WaiterConfiguration config, params LifecycleState[] targetStates)
        {
            var agent = new WaiterAgent <GetDetectorRequest, GetDetectorResponse>(
                request,
                request => client.GetDetector(request),
                response => targetStates.Contains(response.Detector.LifecycleState.Value),
                targetStates.Contains(LifecycleState.Deleted)
                );

            return(new Waiter <GetDetectorRequest, GetDetectorResponse>(config, agent));
        }
        private void HandleOutput(GetDetectorRequest request)
        {
            var waiterConfig = new WaiterConfiguration
            {
                MaxAttempts           = MaxWaitAttempts,
                GetNextDelayInSeconds = (_) => WaitIntervalSeconds
            };

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

            case Default:
                response = client.GetDetector(request).GetAwaiter().GetResult();
                break;
            }
            WriteOutput(response, response.Detector);
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            GetDetectorRequest request;

            try
            {
                request = new GetDetectorRequest
                {
                    DetectorId   = DetectorId,
                    OpcRequestId = OpcRequestId
                };

                HandleOutput(request);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Ejemplo n.º 4
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 <GetDetectorRequest, GetDetectorResponse> ForDetector(GetDetectorRequest request, params LifecycleState[] targetStates)
 {
     return(this.ForDetector(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates));
 }