protected override void ProcessRecord()
        {
            base.ProcessRecord();

            if (!ConfirmDelete("OCIApigatewayDeployment", "Remove"))
            {
                return;
            }

            DeleteDeploymentRequest request;

            try
            {
                request = new DeleteDeploymentRequest
                {
                    DeploymentId = DeploymentId,
                    IfMatch      = IfMatch,
                    OpcRequestId = OpcRequestId
                };

                response = client.DeleteDeployment(request).GetAwaiter().GetResult();
                WriteOutput(response, CreateWorkRequestObject(response.OpcWorkRequestId));
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
        /// <summary>
        /// Deletes the deployment with the given 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>
        public async Task <DeleteDeploymentResponse> DeleteDeployment(DeleteDeploymentRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
        {
            logger.Trace("Called deleteDeployment");
            Uri                uri            = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/deployments/{deploymentId}".Trim('/')));
            HttpMethod         method         = new HttpMethod("Delete");
            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);
                }
                else
                {
                    responseMessage = await this.restClient.HttpSend(requestMessage);
                }

                return(Converter.FromHttpResponseMessage <DeleteDeploymentResponse>(responseMessage));
            }
            catch (Exception e)
            {
                logger.Error($"DeleteDeployment failed with error: {e.Message}");
                throw;
            }
        }
        public async Task <IActionResult> Delete([FromRoute] string id)
        {
            var request = new DeleteDeploymentRequest(id);
            await _mediator.Send(request);

            return(NoContent());
        }
Exemple #4
0
        public async Task <IActionResult> DeleteDeployment(string productName, string deploymentName, CancellationToken cancellationToken = default)
        {
            var request = new DeleteDeploymentRequest()
            {
                ProductName    = productName,
                DeploymentName = deploymentName
            };

            await _mediator.Send(request, cancellationToken);

            return(NoContent());
        }
        /// <summary>Snippet for DeleteDeployment</summary>
        public void DeleteDeploymentRequestObject()
        {
            // Snippet: DeleteDeployment(DeleteDeploymentRequest, CallSettings)
            // Create client
            GSuiteAddOnsClient gSuiteAddOnsClient = GSuiteAddOnsClient.Create();
            // Initialize request argument(s)
            DeleteDeploymentRequest request = new DeleteDeploymentRequest
            {
                DeploymentName = DeploymentName.FromProjectDeployment("[PROJECT]", "[DEPLOYMENT]"),
                Etag           = "",
            };

            // Make the request
            gSuiteAddOnsClient.DeleteDeployment(request);
            // End snippet
        }
        /// <summary>Snippet for DeleteDeploymentAsync</summary>
        public async Task DeleteDeploymentRequestObjectAsync()
        {
            // Snippet: DeleteDeploymentAsync(DeleteDeploymentRequest, CallSettings)
            // Additional: DeleteDeploymentAsync(DeleteDeploymentRequest, CancellationToken)
            // Create client
            GSuiteAddOnsClient gSuiteAddOnsClient = await GSuiteAddOnsClient.CreateAsync();

            // Initialize request argument(s)
            DeleteDeploymentRequest request = new DeleteDeploymentRequest
            {
                DeploymentName = DeploymentName.FromProjectDeployment("[PROJECT]", "[DEPLOYMENT]"),
                Etag           = "",
            };
            // Make the request
            await gSuiteAddOnsClient.DeleteDeploymentAsync(request);

            // End snippet
        }
Exemple #7
0
        private void StopDeployment(Deployment deployment)
        {
            Log.Logger.Information("Stopping {dplName}", deployment.Name);
            // Update any tag changes
            UpdateDeployment(deployment);

            // Stop the deployment
            var deleteDeploymentRequest = new DeleteDeploymentRequest
            {
                Id = deployment.Id
            };

            try
            {
                var startTime = DateTime.Now;
                Reporter.ReportDeploymentStopRequest(matchType);
                var deleteOp = deploymentServiceClient.DeleteDeployment(deleteDeploymentRequest);
                Task.Run(() =>
                {
                    var completed = deleteOp.PollUntilCompleted();
                    Reporter.ReportDeploymentStopDuration(matchType, (DateTime.Now - startTime).TotalSeconds);
                    if (completed.IsCompleted)
                    {
                        Log.Logger.Information("Deployment {dplName} stopped succesfully", completed.Result.Name);
                    }
                    else if (completed.IsFaulted)
                    {
                        Log.Logger.Error("Failed to stop deployment {DplName}. Operation {opName}. Error {err}", deployment.Name, completed.Name, completed.Exception.Message);
                    }
                    else
                    {
                        Log.Logger.Error("Internal error stopping deployment {dplName}. Operation {opName}. Error {err}", completed.Result.Name, completed.Name, completed.Exception.Message);
                    }
                });
            }
            catch (RpcException e)
            {
                Reporter.ReportDeploymentStopFailure(matchType);
                Log.Logger.Warning("Failed to start deployment deletion. Error: {err}", e.Message);
            }
        }