|
| 1 | +/* |
| 2 | + * NOTE: Generated using OracleSDKGenerator, API Version: 20190501 |
| 3 | + * DO NOT EDIT this file manually. |
| 4 | + * |
| 5 | + * Copyright (c) 2020, Oracle and/or its affiliates. |
| 6 | + * This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. |
| 7 | + */ |
| 8 | + |
| 9 | +using System; |
| 10 | +using System.Management.Automation; |
| 11 | +using Oci.ApigatewayService.Requests; |
| 12 | +using Oci.ApigatewayService.Responses; |
| 13 | +using Oci.ApigatewayService.Models; |
| 14 | +using Oci.Common.Waiters; |
| 15 | + |
| 16 | +namespace Oci.ApigatewayService.Cmdlets |
| 17 | +{ |
| 18 | + [Cmdlet("Get", "OCIApigatewayApi", DefaultParameterSetName = Default)] |
| 19 | + [OutputType(new System.Type[] { typeof(Oci.ApigatewayService.Models.Api), typeof(Oci.ApigatewayService.Responses.GetApiResponse) })] |
| 20 | + public class GetOCIApigatewayApi : OCIApiGatewayCmdlet |
| 21 | + { |
| 22 | + |
| 23 | + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = @"The ocid of the API.", ParameterSetName = LifecycleStateParamSet)] |
| 24 | + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = @"The ocid of the API.", ParameterSetName = Default)] |
| 25 | + public string ApiId { get; set; } |
| 26 | + |
| 27 | + |
| 28 | + [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = @"The client request id for tracing.", ParameterSetName = LifecycleStateParamSet)] |
| 29 | + [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = @"The client request id for tracing.", ParameterSetName = Default)] |
| 30 | + public string OpcRequestId { get; set; } |
| 31 | + |
| 32 | + [Parameter(Mandatory = true, HelpMessage = @"This operation creates, modifies or deletes a resource that has a defined lifecycle state. Specify this option to perform the action and then wait until the resource reaches a given lifecycle state. Multiple states can be specified, returning on the first state.", ParameterSetName = LifecycleStateParamSet)] |
| 33 | + public Oci.ApigatewayService.Models.Api.LifecycleStateEnum[] WaitForLifecycleState { get; set; } |
| 34 | + |
| 35 | + [Parameter(Mandatory = false, HelpMessage = @"Check every WaitIntervalSeconds to see whether the resource has reached a desired state.", ParameterSetName = LifecycleStateParamSet)] |
| 36 | + public int WaitIntervalSeconds { get; set; } = WAIT_INTERVAL_SECONDS; |
| 37 | + |
| 38 | + [Parameter(Mandatory = false, HelpMessage = @"Maximum number of attempts to be made until the resource reaches a desired state.", ParameterSetName = LifecycleStateParamSet)] |
| 39 | + public int MaxWaitAttempts { get; set; } = MAX_WAITER_ATTEMPTS; |
| 40 | + |
| 41 | + protected override void ProcessRecord() |
| 42 | + { |
| 43 | + base.ProcessRecord(); |
| 44 | + GetApiRequest request; |
| 45 | + |
| 46 | + try |
| 47 | + { |
| 48 | + request = new GetApiRequest |
| 49 | + { |
| 50 | + ApiId = ApiId, |
| 51 | + OpcRequestId = OpcRequestId |
| 52 | + }; |
| 53 | + |
| 54 | + HandleOutput(request); |
| 55 | + FinishProcessing(response); |
| 56 | + } |
| 57 | + catch (Exception ex) |
| 58 | + { |
| 59 | + TerminatingErrorDuringExecution(ex); |
| 60 | + } |
| 61 | + } |
| 62 | + |
| 63 | + protected override void StopProcessing() |
| 64 | + { |
| 65 | + base.StopProcessing(); |
| 66 | + TerminatingErrorDuringExecution(new OperationCanceledException("Cmdlet execution interrupted")); |
| 67 | + } |
| 68 | + |
| 69 | + private void HandleOutput(GetApiRequest request) |
| 70 | + { |
| 71 | + var waiterConfig = new WaiterConfiguration |
| 72 | + { |
| 73 | + MaxAttempts = MaxWaitAttempts, |
| 74 | + GetNextDelayInSeconds = (_) => WaitIntervalSeconds |
| 75 | + }; |
| 76 | + |
| 77 | + switch (ParameterSetName) |
| 78 | + { |
| 79 | + case LifecycleStateParamSet: |
| 80 | + response = client.Waiters.ForApi(request, waiterConfig, WaitForLifecycleState).Execute(); |
| 81 | + break; |
| 82 | + |
| 83 | + case Default: |
| 84 | + response = client.GetApi(request).GetAwaiter().GetResult(); |
| 85 | + break; |
| 86 | + } |
| 87 | + WriteOutput(response, response.Api); |
| 88 | + } |
| 89 | + |
| 90 | + private GetApiResponse response; |
| 91 | + private const string LifecycleStateParamSet = "LifecycleStateParamSet"; |
| 92 | + private const string Default = "Default"; |
| 93 | + } |
| 94 | +} |
0 commit comments