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 <GetWaasPolicyRequest, GetWaasPolicyResponse> ForWaasPolicy(GetWaasPolicyRequest request, WaiterConfiguration config, params LifecycleStates[] targetStates)
        {
            var agent = new WaiterAgent <GetWaasPolicyRequest, GetWaasPolicyResponse>(
                request,
                request => client.GetWaasPolicy(request),
                response => targetStates.Contains(response.WaasPolicy.LifecycleState.Value),
                targetStates.Contains(LifecycleStates.Deleted)
                );

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

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

            case Default:
                response = client.GetWaasPolicy(request).GetAwaiter().GetResult();
                break;
            }
            WriteOutput(response, response.WaasPolicy);
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            GetWaasPolicyRequest request;

            try
            {
                request = new GetWaasPolicyRequest
                {
                    WaasPolicyId = WaasPolicyId,
                    OpcRequestId = OpcRequestId
                };

                HandleOutput(request);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the details of a WAAS policy.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public GetWaasPolicyResponse GetWaasPolicy(GetWaasPolicyRequest request)
        {
            var uri = new Uri($"{GetEndPoint(WaasServices.WaasPolicies, this.Region)}/{request.WaasPolicyId}");

            var httpRequestHeaderParam = new HttpRequestHeaderParam()
            {
                OpcRequestId = request.OpcRequestId
            };

            using (var webResponse = this.RestClient.Get(uri, httpRequestHeaderParam))
                using (var stream = webResponse.GetResponseStream())
                    using (var reader = new StreamReader(stream))
                    {
                        var response = reader.ReadToEnd();

                        return(new GetWaasPolicyResponse()
                        {
                            WaasPolicy = this.JsonSerializer.Deserialize <WaasPolicyDetails>(response),
                            OpcRequestId = webResponse.Headers.Get("opc-request-id"),
                            ETag = webResponse.Headers.Get("etag")
                        });
                    }
        }
Ejemplo n.º 5
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 <GetWaasPolicyRequest, GetWaasPolicyResponse> ForWaasPolicy(GetWaasPolicyRequest request, params LifecycleStates[] targetStates)
 {
     return(this.ForWaasPolicy(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates));
 }