/// <summary> /// Creates a new gateway. /// /// </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/CreateGateway.cs.html">here</a> to see an example of how to use CreateGateway API.</example> public async Task <CreateGatewayResponse> CreateGateway(CreateGatewayRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default) { logger.Trace("Called createGateway"); Uri uri = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/gateways".Trim('/'))); HttpMethod method = new HttpMethod("POST"); 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 <CreateGatewayResponse>(responseMessage)); } catch (Exception e) { logger.Error($"CreateGateway failed with error: {e.Message}"); throw; } }
/// <summary>Snippet for CreateGateway</summary> /// <remarks> /// This snippet has been automatically generated for illustrative purposes only. /// It may require modifications to work in your environment. /// </remarks> public void CreateGatewayRequestObject() { // Create client ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.Create(); // Initialize request argument(s) CreateGatewayRequest request = new CreateGatewayRequest { ParentAsLocationName = LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"), GatewayId = "", Gateway = new Gateway(), }; // Make the request Operation <Gateway, OperationMetadata> response = apiGatewayServiceClient.CreateGateway(request); // Poll until the returned long-running operation is complete Operation <Gateway, OperationMetadata> completedResponse = response.PollUntilCompleted(); // Retrieve the operation result Gateway result = completedResponse.Result; // Or get the name of the operation string operationName = response.Name; // This name can be stored, then the long-running operation retrieved later by name Operation <Gateway, OperationMetadata> retrievedResponse = apiGatewayServiceClient.PollOnceCreateGateway(operationName); // Check if the retrieved long-running operation has completed if (retrievedResponse.IsCompleted) { // If it has completed, then access the result Gateway retrievedResult = retrievedResponse.Result; } }
/// <summary> /// Creates a backup gateway. After you create a gateway, you can associate it with a /// server using the <code>AssociateGatewayToServer</code> operation. /// </summary> /// <param name="request">Container for the necessary parameters to execute the CreateGateway service method.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// /// <returns>The response from the CreateGateway service method, as returned by BackupGateway.</returns> /// <exception cref="Amazon.BackupGateway.Model.InternalServerException"> /// The operation did not succeed because an internal error occurred. Try again later. /// </exception> /// <exception cref="Amazon.BackupGateway.Model.ValidationException"> /// The operation did not succeed because a validation error occurred. /// </exception> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/backup-gateway-2021-01-01/CreateGateway">REST API Reference for CreateGateway Operation</seealso> public virtual Task <CreateGatewayResponse> CreateGatewayAsync(CreateGatewayRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = CreateGatewayRequestMarshaller.Instance; options.ResponseUnmarshaller = CreateGatewayResponseUnmarshaller.Instance; return(InvokeAsync <CreateGatewayResponse>(request, options, cancellationToken)); }
internal virtual CreateGatewayResponse CreateGateway(CreateGatewayRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = CreateGatewayRequestMarshaller.Instance; options.ResponseUnmarshaller = CreateGatewayResponseUnmarshaller.Instance; return(Invoke <CreateGatewayResponse>(request, options)); }
protected override void ProcessRecord() { base.ProcessRecord(); CreateGatewayRequest request; try { request = new CreateGatewayRequest { CreateGatewayDetails = CreateGatewayDetails, OpcRetryToken = OpcRetryToken, OpcRequestId = OpcRequestId }; response = client.CreateGateway(request).GetAwaiter().GetResult(); WriteOutput(response, response.Gateway); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }