Beispiel #1
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ListShapesRequest request;

            try
            {
                request = new ListShapesRequest
                {
                    CompartmentId = CompartmentId,
                    OpcRequestId  = OpcRequestId,
                    Limit         = Limit,
                    Page          = Page
                };
                IEnumerable <ListShapesResponse> 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);
            }
        }
Beispiel #2
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ListShapesRequest request;

            try
            {
                request = new ListShapesRequest
                {
                    CompartmentId      = CompartmentId,
                    OpcRequestId       = OpcRequestId,
                    IsSupportedFor     = IsSupportedFor,
                    AvailabilityDomain = AvailabilityDomain,
                    Name = Name
                };

                response = client.ListShapes(request).GetAwaiter().GetResult();
                WriteOutput(response, response.Items, true);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Gets a list of the shapes you can use to create a new MySQL DB System.
        /// The shape determines the resources allocated to the DB System:
        /// CPU cores and memory for VM shapes; CPU cores, memory and
        /// storage for non-VM (or bare metal) shapes.
        ///
        /// </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/mysql/ListShapes.cs.html">here</a> to see an example of how to use ListShapes API.</example>
        public async Task <ListShapesResponse> ListShapes(ListShapesRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
        {
            logger.Trace("Called listShapes");
            Uri                uri            = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/shapes".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 <ListShapesResponse>(responseMessage));
            }
            catch (Exception e)
            {
                logger.Error($"ListShapes failed with error: {e.Message}");
                throw;
            }
        }
Beispiel #4
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            ListShapesRequest request;

            try
            {
                request = new ListShapesRequest
                {
                    CompartmentId      = CompartmentId,
                    AvailabilityDomain = AvailabilityDomain,
                    Limit   = Limit,
                    Page    = Page,
                    ImageId = ImageId
                };
                IEnumerable <ListShapesResponse> responses = GetRequestDelegate().Invoke(request);
                foreach (var item in responses)
                {
                    response = item;
                    WriteOutput(response, response.Items, true);
                }
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
        private static async Task <Shape> getShape(ComputeClient client, string compartmentId, AvailabilityDomain availabilityDomain)
        {
            ListShapesRequest listShapesRequest = new ListShapesRequest
            {
                CompartmentId      = compartmentId,
                AvailabilityDomain = availabilityDomain.Name
            };
            ListShapesResponse listShapesResponse = await client.ListShapes(listShapesRequest);

            Shape shape = listShapesResponse.Items.Find(x => x.ShapeProp.StartsWith("VM"));

            return(shape);
        }
Beispiel #6
0
 /// <summary>
 /// Creates a new enumerable which will iterate over the responses received from the ListShapes 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 <ListShapesResponse> ListShapesResponseEnumerator(ListShapesRequest request, Common.Retry.RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
 {
     return(new Common.Utils.ResponseEnumerable <ListShapesRequest, ListShapesResponse>(
                response => response.OpcNextPage,
                input =>
     {
         if (!string.IsNullOrEmpty(input))
         {
             request.Page = input;
         }
         return request;
     },
                request => client.ListShapes(request, retryConfiguration, cancellationToken)
                ));
 }
        /// <summary>
        /// Lists the shapes that can be used to launch an instance within the specified compartment.
        /// You can filter the list by compatibility with a specific image.
        /// </summary>
        /// <param name="listRequest"></param>
        /// <returns></returns>
        public async Task <ListShapesResponse> ListShapes(ListShapesRequest listRequest)
        {
            var uri = new Uri($"{GetEndPoint(CoreServices.Shape, this.Region)}?{listRequest.GetOptionQuery()}");

            using (var webResponse = await this.RestClientAsync.Get(uri))
                using (var stream = webResponse.GetResponseStream())
                    using (var reader = new StreamReader(stream))
                    {
                        var response = await reader.ReadToEndAsync();

                        return(new ListShapesResponse()
                        {
                            Items = this.JsonSerializer.Deserialize <List <ShapeModel> >(response),
                            OpcRequestId = webResponse.Headers.Get("opc-request-id"),
                            OpcNextPage = webResponse.Headers.Get("opc-next-page")
                        });
                    }
        }