/// <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 <GetKeyVersionRequest, GetKeyVersionResponse> ForKeyVersion(GetKeyVersionRequest request, WaiterConfiguration config, params KeyVersion.LifecycleStateEnum[] targetStates)
        {
            var agent = new WaiterAgent <GetKeyVersionRequest, GetKeyVersionResponse>(
                request,
                request => client.GetKeyVersion(request),
                response => targetStates.Contains(response.KeyVersion.LifecycleState.Value),
                targetStates.Contains(KeyVersion.LifecycleStateEnum.Deleted)
                );

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

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

            case Default:
                response = client.GetKeyVersion(request).GetAwaiter().GetResult();
                break;
            }
            WriteOutput(response, response.KeyVersion);
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            GetKeyVersionRequest request;

            try
            {
                request = new GetKeyVersionRequest
                {
                    KeyId        = KeyId,
                    KeyVersionId = KeyVersionId,
                    OpcRequestId = OpcRequestId
                };

                HandleOutput(request);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
 /// <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 <GetKeyVersionRequest, GetKeyVersionResponse> ForKeyVersion(GetKeyVersionRequest request, params KeyVersion.LifecycleStateEnum[] targetStates)
 {
     return(this.ForKeyVersion(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates));
 }