Пример #1
0
        /// <summary>
        /// Gets information about the specified steering policy attachment.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public GetSteeringPolicyAttachmentResponse GetSteeringPolicyAttachment(GetSteeringPolicyAttachmentRequest request)
        {
            var uriStr = $"{GetEndPoint(DNSServices.SteeringPolicyAttachments, this.Region)}/{request.SteeringPolicyAttachmentId}";

            var uri = new Uri(uriStr);

            var httpRequestHeaderParam = new HttpRequestHeaderParam()
            {
                IfNoneMatch     = request.IfNoneMatch,
                IfModifiedSince = request.IfModifiedSince
            };
            var webResponse = this.RestClient.Get(uri, httpRequestHeaderParam);

            using (var stream = webResponse.GetResponseStream())
                using (var reader = new StreamReader(stream))
                {
                    var response = reader.ReadToEnd();

                    return(new GetSteeringPolicyAttachmentResponse()
                    {
                        SteeringPolicyAttachment = this.JsonSerializer.Deserialize <SteeringPolicyAttachmentDetails>(response),
                        OpcRequestId = webResponse.Headers.Get("opc-request-id"),
                        ETag = webResponse.Headers.Get("ETag")
                    });
                }
        }
        private void HandleOutput(GetSteeringPolicyAttachmentRequest request)
        {
            var waiterConfig = new WaiterConfiguration
            {
                MaxAttempts           = MaxWaitAttempts,
                GetNextDelayInSeconds = (_) => WaitIntervalSeconds
            };

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

            case Default:
                response = client.GetSteeringPolicyAttachment(request).GetAwaiter().GetResult();
                break;
            }
            WriteOutput(response, response.SteeringPolicyAttachment);
        }
Пример #3
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            GetSteeringPolicyAttachmentRequest request;

            try
            {
                request = new GetSteeringPolicyAttachmentRequest
                {
                    SteeringPolicyAttachmentId = SteeringPolicyAttachmentId,
                    IfNoneMatch     = IfNoneMatch,
                    IfModifiedSince = IfModifiedSince,
                    OpcRequestId    = OpcRequestId
                };

                HandleOutput(request);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Пример #4
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 <GetSteeringPolicyAttachmentRequest, GetSteeringPolicyAttachmentResponse> ForSteeringPolicyAttachment(GetSteeringPolicyAttachmentRequest request, WaiterConfiguration config, params SteeringPolicyAttachment.LifecycleStateEnum[] targetStates)
        {
            var agent = new WaiterAgent <GetSteeringPolicyAttachmentRequest, GetSteeringPolicyAttachmentResponse>(
                request,
                request => client.GetSteeringPolicyAttachment(request),
                response => targetStates.Contains(response.SteeringPolicyAttachment.LifecycleState.Value)
                );

            return(new Waiter <GetSteeringPolicyAttachmentRequest, GetSteeringPolicyAttachmentResponse>(config, agent));
        }
Пример #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 <GetSteeringPolicyAttachmentRequest, GetSteeringPolicyAttachmentResponse> ForSteeringPolicyAttachment(GetSteeringPolicyAttachmentRequest request, params SteeringPolicyAttachment.LifecycleStateEnum[] targetStates)
 {
     return(this.ForSteeringPolicyAttachment(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates));
 }