Example #1
0
        /// <summary>
        /// Gets the confirmation details for the specified subscription.
        /// &lt;br/&gt;
        /// Transactions Per Minute (TPM) per-tenancy limit for this operation: 60.
        ///
        /// </summary>
        /// <param name="request">The request object containing the details to send. Required.</param>
        /// <param name="retryConfiguration">The retry configuration that will be used by to send this request. Optional.</param>
        /// <param name="cancellationToken">The cancellation token to cancel this operation. Optional.</param>
        /// <returns>A response object containing details about the completed operation</returns>
        /// <example>Click <a href="https://docs.cloud.oracle.com/en-us/iaas/tools/dot-net-examples/latest/ons/GetConfirmSubscription.cs.html">here</a> to see an example of how to use GetConfirmSubscription API.</example>
        public async Task <GetConfirmSubscriptionResponse> GetConfirmSubscription(GetConfirmSubscriptionRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
        {
            logger.Trace("Called getConfirmSubscription");
            Uri                uri            = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/subscriptions/{id}/confirmation".Trim('/')));
            HttpMethod         method         = new HttpMethod("GET");
            HttpRequestMessage requestMessage = Converter.ToHttpRequestMessage(uri, method, request);

            requestMessage.Headers.Add("Accept", "application/json");
            GenericRetrier      retryingClient = Retrier.GetPreferredRetrier(retryConfiguration, this.retryConfiguration);
            HttpResponseMessage responseMessage;

            try
            {
                if (retryingClient != null)
                {
                    responseMessage = await retryingClient.MakeRetryingCall(this.restClient.HttpSend, requestMessage, cancellationToken).ConfigureAwait(false);
                }
                else
                {
                    responseMessage = await this.restClient.HttpSend(requestMessage).ConfigureAwait(false);
                }
                this.restClient.CheckHttpResponseMessage(requestMessage, responseMessage);

                return(Converter.FromHttpResponseMessage <GetConfirmSubscriptionResponse>(responseMessage));
            }
            catch (Exception e)
            {
                logger.Error($"GetConfirmSubscription failed with error: {e.Message}");
                throw;
            }
        }
        /// <summary>
        /// Gets the confirmation details for the specified subscription.
        /// Transactions Per Minute (TPM) per-tenancy limit for this operation: 60.
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public async Task <GetConfirmSubscriptionResponse> GetConfirmSubscription(GetConfirmSubscriptionRequest request)
        {
            var uri = new Uri($"{GetEndPoint(NotificationServices.Subscriptions, this.Region)}/{request.Id}/confirmation?{request.GetOptionQuery()}");

            var httpRequestHeaderParam = new HttpRequestHeaderParam()
            {
                OpcRequestId = request.OpcRequestId
            };
            var webResponse = await this.RestClientAsync.Get(uri, httpRequestHeaderParam);

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

                    return(new GetConfirmSubscriptionResponse()
                    {
                        ConfirmationResult = this.JsonSerializer.Deserialize <ConfirmationResult>(response),
                        OpcRequestId = webResponse.Headers.Get("opc-request-id"),
                        ETag = webResponse.Headers.Get("etag")
                    });
                }
        }
Example #3
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            GetConfirmSubscriptionRequest request;

            try
            {
                request = new GetConfirmSubscriptionRequest
                {
                    Id           = Id,
                    Token        = Token,
                    Protocol     = Protocol,
                    OpcRequestId = OpcRequestId
                };

                response = client.GetConfirmSubscription(request).GetAwaiter().GetResult();
                WriteOutput(response, response.ConfirmationResult);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }