Example #1
0
        /// <summary>
        /// Gets the list of packages for a listing.
        /// &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/ListPackages.cs.html">here</a> to see an example of how to use ListPackages API.</example>
        public async Task <ListPackagesResponse> ListPackages(ListPackagesRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
        {
            logger.Trace("Called listPackages");
            Uri                uri            = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/listings/{listingId}/packages".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 <ListPackagesResponse>(responseMessage));
            }
            catch (Exception e)
            {
                logger.Error($"ListPackages failed with error: {e.Message}");
                throw;
            }
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ListPackagesRequest request;

            try
            {
                request = new ListPackagesRequest
                {
                    ListingId      = ListingId,
                    PackageVersion = PackageVersion,
                    PackageType    = PackageType,
                    OpcRequestId   = OpcRequestId,
                    Limit          = Limit,
                    Page           = Page,
                    SortBy         = SortBy,
                    SortOrder      = SortOrder,
                    CompartmentId  = CompartmentId
                };
                IEnumerable <ListPackagesResponse> responses = GetRequestDelegate().Invoke(request);
                foreach (var item in responses)
                {
                    response = item;
                    WriteOutput(response, response.Items, true);
                }
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Example #3
0
        public async Task <IEnumerable <string> > ListPackagesAsync(string accessToken = null, TraceContext traceContext = null)
        {
            var request = new ListPackagesRequest {
                LedgerId = LedgerId, TraceContext = traceContext
            };
            var response = await _packageClient.WithAccess(accessToken).Dispatch(request, (c, r, co) => c.ListPackagesAsync(r, co));

            return(response.PackageIds);
        }
 /// <summary>
 /// Creates a new enumerable which will iterate over the responses received from the ListPackages operation. This enumerable
 /// will fetch more data from the server as needed.
 /// </summary>
 /// <param name="request">The request object containing the details to send</param>
 /// <param name="retryConfiguration">The configuration for retrying, may be null</param>
 /// <param name="cancellationToken">The cancellation token object</param>
 /// <returns>The enumerator, which supports a simple iteration over a collection of a specified type</returns>
 public IEnumerable <ListPackagesResponse> ListPackagesResponseEnumerator(ListPackagesRequest request, Common.Retry.RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
 {
     return(new Common.Utils.ResponseEnumerable <ListPackagesRequest, ListPackagesResponse>(
                response => response.OpcNextPage,
                input =>
     {
         if (!string.IsNullOrEmpty(input))
         {
             request.Page = input;
         }
         return request;
     },
                request => client.ListPackages(request, retryConfiguration, cancellationToken)
                ));
 }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ListPackagesRequest request;

            try
            {
                request = new ListPackagesRequest
                {
                    ListingId      = ListingId,
                    PackageVersion = PackageVersion,
                    PackageType    = PackageType,
                    OpcRequestId   = OpcRequestId,
                    Limit          = Limit,
                    Page           = Page,
                    SortBy         = SortBy,
                    SortOrder      = SortOrder,
                    CompartmentId  = CompartmentId
                };
                IEnumerable <ListPackagesResponse> responses = GetRequestDelegate().Invoke(request);
                foreach (var item in responses)
                {
                    response = item;
                    WriteOutput(response, response.Items, true);
                }
                if (!ParameterSetName.Equals(AllPageSet) && !ParameterSetName.Equals(LimitSet) && response.OpcNextPage != null)
                {
                    WriteWarning("This operation supports pagination and not all resources were returned. Re-run using the -All option to auto paginate and list all resources.");
                }
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }