Example #1
0
        /// <summary>
        /// Get the details of the specified version of a package, including information needed to launch the package.
        /// &lt;br/&gt;
        /// If you plan to launch an instance from an image listing, you must first subscribe to the listing. When
        /// you launch the instance, you also need to provide the image ID of the listing resource version that you want.
        /// &lt;br/&gt;
        /// Subscribing to the listing requires you to first get a signature from the terms of use agreement for the
        /// listing resource version. To get the signature, issue a [GetAppCatalogListingAgreements](https://docs.cloud.oracle.com/en-us/iaas/api/#/en/iaas/latest/AppCatalogListingResourceVersionAgreements/GetAppCatalogListingAgreements) API call.
        /// The [AppCatalogListingResourceVersionAgreements](https://docs.cloud.oracle.com/en-us/iaas/api/#/en/iaas/latest/AppCatalogListingResourceVersionAgreements) object, including
        /// its signature, is returned in the response. With the signature for the terms of use agreement for the desired
        /// listing resource version, create a subscription by issuing a
        /// [CreateAppCatalogSubscription](https://docs.cloud.oracle.com/en-us/iaas/api/#/en/iaas/latest/AppCatalogSubscription/CreateAppCatalogSubscription) API call.
        /// &lt;br/&gt;
        /// To get the image ID to launch an instance, issue a [GetAppCatalogListingResourceVersion](https://docs.cloud.oracle.com/en-us/iaas/api/#/en/iaas/latest/AppCatalogListingResourceVersion/GetAppCatalogListingResourceVersion) API call.
        /// Lastly, to launch the instance, use the image ID of the listing resource version to issue a [LaunchInstance](https://docs.cloud.oracle.com/en-us/iaas/api/#/en/iaas/latest/Instance/LaunchInstance) API call.
        ///
        /// </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/marketplace/GetPackage.cs.html">here</a> to see an example of how to use GetPackage API.</example>
        public async Task <GetPackageResponse> GetPackage(GetPackageRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
        {
            logger.Trace("Called getPackage");
            Uri                uri            = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/listings/{listingId}/packages/{packageVersion}".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 <GetPackageResponse>(responseMessage));
            }
            catch (Exception e)
            {
                logger.Error($"GetPackage failed with error: {e.Message}");
                throw;
            }
        }
Example #2
0
        public async Task <GetPackageResponse> GetPackageAsync(string packageId, string accessToken = null, TraceContext traceContext = null)
        {
            var request = new GetPackageRequest {
                LedgerId = LedgerId, PackageId = packageId, TraceContext = traceContext
            };

            return(await _packageClient.WithAccess(accessToken).Dispatch(request, (c, r, co) => c.GetPackageAsync(r, co)));
        }
Example #3
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            GetPackageRequest request;

            try
            {
                request = new GetPackageRequest
                {
                    ListingId      = ListingId,
                    PackageVersion = PackageVersion,
                    OpcRequestId   = OpcRequestId,
                    CompartmentId  = CompartmentId
                };

                response = client.GetPackage(request).GetAwaiter().GetResult();
                WriteOutput(response, response.ListingPackage);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Example #4
0
        public IHttpActionResult GetPackage([FromUri] GetPackageRequest getPackageRequest)
        {
            var responses = new Responses();

            try
            {
                if (Utility.UserId < 0)
                {
                    return(BadRequest(Utility.INVALID_USER));
                }

                if (getPackageRequest == null)
                {
                    getPackageRequest = new GetPackageRequest();
                }

                if (getPackageRequest.PageSize == null)
                {
                    getPackageRequest.PageSize = Convert.ToInt32(ConfigurationManager.AppSettings["PageSize"]);
                }

                var package = new Package()
                {
                    PackageId        = getPackageRequest.PackageId,
                    SearchText       = getPackageRequest.SearchText,
                    IsActive         = getPackageRequest.IsActive,
                    PageNumber       = getPackageRequest.PageNumber,
                    PageSize         = Convert.ToInt32(getPackageRequest.PageSize),
                    IsPagingRequired = (getPackageRequest.PageNumber != null) ? true : false,
                    OrderBy          = getPackageRequest.OrderBy,
                    OrderByDirection = getPackageRequest.OrderByDirection
                };
                var packages = iPackage.GetPackage(package);

                var packageList = new List <GetPackageResponse>();
                foreach (var packageDetail in packages)
                {
                    packageList.Add(new GetPackageResponse()
                    {
                        PackageId       = Convert.ToInt32(packageDetail.PackageId),
                        PackageName     = packageDetail.PackageName,
                        PackageDuration = packageDetail.PackageDuration,
                        Amount          = packageDetail.Amount,
                        PackageTypeId   = packageDetail.PackageTypeId,
                        PackageTypeName = packageDetail.PackageTypeName,
                        IsActive        = Convert.ToBoolean(packageDetail.IsActive),
                        CreatedBy       = packageDetail.CreatedBy,
                        TotalPageCount  = packageDetail.TotalPageCount,
                        TotalRecord     = packageDetail.TotalRecord
                    });
                }

                responses.Status      = Utility.SUCCESS_STATUS_RESPONSE;
                responses.Description = "Package retrieved successfully";
                responses.Response    = packageList;
            }
            catch (Exception ex)
            {
                responses.Status      = Utility.ERROR_STATUS_RESPONSE;
                responses.Description = "Error while retrieving Package.";

                Utility.WriteLog("GetPackage", getPackageRequest, "Error while retrieving Package. (PackageUserController)", ex.ToString());
            }
            return(Ok(responses));
        }