Beispiel #1
0
        /// <summary>
        /// Gets an API by identifier.
        /// </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/apigateway/GetApi.cs.html">here</a> to see an example of how to use GetApi API.</example>
        public async Task <GetApiResponse> GetApi(GetApiRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
        {
            logger.Trace("Called getApi");
            Uri                uri            = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/apis/{apiId}".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 <GetApiResponse>(responseMessage));
            }
            catch (Exception e)
            {
                logger.Error($"GetApi failed with error: {e.Message}");
                throw;
            }
        }
        public void GetApiResourceNames()
        {
            moq::Mock <ApiGatewayService.ApiGatewayServiceClient> mockGrpcClient = new moq::Mock <ApiGatewayService.ApiGatewayServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetApiRequest request = new GetApiRequest
            {
                ApiName = ApiName.FromProjectApi("[PROJECT]", "[API]"),
            };
            Api expectedResponse = new Api
            {
                ApiName    = ApiName.FromProjectApi("[PROJECT]", "[API]"),
                CreateTime = new wkt::Timestamp(),
                UpdateTime = new wkt::Timestamp(),
                Labels     =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                DisplayName = "display_name137f65c2",
                ManagedServiceAsManagedServiceName = ManagedServiceName.FromService("[SERVICE]"),
                State = Api.Types.State.Unspecified,
            };

            mockGrpcClient.Setup(x => x.GetApi(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            ApiGatewayServiceClient client = new ApiGatewayServiceClientImpl(mockGrpcClient.Object, null);
            Api response = client.GetApi(request.ApiName);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>
        /// Creates a waiter using the provided configuration.
        /// </summary>
        /// <param name="request">Request to send.</param>
        /// <param name="config">Wait Configuration</param>
        /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param>
        /// <returns>a new Oci.common.Waiter instance</returns>
        public Waiter <GetApiRequest, GetApiResponse> ForApi(GetApiRequest request, WaiterConfiguration config, params Api.LifecycleStateEnum[] targetStates)
        {
            var agent = new WaiterAgent <GetApiRequest, GetApiResponse>(
                request,
                request => client.GetApi(request),
                response => targetStates.Contains(response.Api.LifecycleState.Value),
                targetStates.Contains(Api.LifecycleStateEnum.Deleted)
                );

            return(new Waiter <GetApiRequest, GetApiResponse>(config, agent));
        }
Beispiel #4
0
 /// <summary>Snippet for GetApi</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetApiRequestObject()
 {
     // Create client
     ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.Create();
     // Initialize request argument(s)
     GetApiRequest request = new GetApiRequest
     {
         ApiName = ApiName.FromProjectApi("[PROJECT]", "[API]"),
     };
     // Make the request
     Api response = apiGatewayServiceClient.GetApi(request);
 }
Beispiel #5
0
        private void HandleOutput(GetApiRequest request)
        {
            var waiterConfig = new WaiterConfiguration
            {
                MaxAttempts           = MaxWaitAttempts,
                GetNextDelayInSeconds = (_) => WaitIntervalSeconds
            };

            switch (ParameterSetName)
            {
            case LifecycleStateParamSet:
                response = client.Waiters.ForApi(request, waiterConfig, WaitForLifecycleState).Execute();
                break;

            case Default:
                response = client.GetApi(request).GetAwaiter().GetResult();
                break;
            }
            WriteOutput(response, response.Api);
        }
Beispiel #6
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            GetApiRequest request;

            try
            {
                request = new GetApiRequest
                {
                    ApiId        = ApiId,
                    OpcRequestId = OpcRequestId
                };

                HandleOutput(request);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
        public async stt::Task GetApiResourceNamesAsync()
        {
            moq::Mock <ApiGatewayService.ApiGatewayServiceClient> mockGrpcClient = new moq::Mock <ApiGatewayService.ApiGatewayServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetApiRequest request = new GetApiRequest
            {
                ApiName = ApiName.FromProjectApi("[PROJECT]", "[API]"),
            };
            Api expectedResponse = new Api
            {
                ApiName    = ApiName.FromProjectApi("[PROJECT]", "[API]"),
                CreateTime = new wkt::Timestamp(),
                UpdateTime = new wkt::Timestamp(),
                Labels     =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                DisplayName = "display_name137f65c2",
                ManagedServiceAsManagedServiceName = ManagedServiceName.FromService("[SERVICE]"),
                State = Api.Types.State.Unspecified,
            };

            mockGrpcClient.Setup(x => x.GetApiAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Api>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            ApiGatewayServiceClient client = new ApiGatewayServiceClientImpl(mockGrpcClient.Object, null);
            Api responseCallSettings       = await client.GetApiAsync(request.ApiName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Api responseCancellationToken = await client.GetApiAsync(request.ApiName, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
 /// <summary>
 /// Creates a waiter using default wait configuration.
 /// </summary>
 /// <param name="request">Request to send.</param>
 /// <param name="targetStates">Desired resource states. If multiple states are provided then the waiter will return once the resource reaches any of the provided states</param>
 /// <returns>a new Oci.common.Waiter instance</returns>
 public Waiter <GetApiRequest, GetApiResponse> ForApi(GetApiRequest request, params Api.LifecycleStateEnum[] targetStates)
 {
     return(this.ForApi(request, WaiterConfiguration.DefaultWaiterConfiguration, targetStates));
 }