/// <summary> /// <para> Causes the environment to restart the application container server running on each Amazon EC2 instance. </para> /// </summary> /// /// <param name="restartAppServerRequest">Container for the necessary parameters to execute the RestartAppServer service method on /// AmazonElasticBeanstalk.</param> /// public RestartAppServerResponse RestartAppServer(RestartAppServerRequest restartAppServerRequest) { IRequest <RestartAppServerRequest> request = new RestartAppServerRequestMarshaller().Marshall(restartAppServerRequest); RestartAppServerResponse response = Invoke <RestartAppServerRequest, RestartAppServerResponse> (request, this.signer, RestartAppServerResponseUnmarshaller.GetInstance()); return(response); }
public async Task <ActionResult> RestartEnvironment(string environmentName) { if (string.IsNullOrEmpty(environmentName)) { throw new ArgumentNullException(nameof(environmentName)); } if (!HomeController.RestartBeanstalkGroups.Any(x => environmentName.StartsWith(x, StringComparison.OrdinalIgnoreCase))) { throw new UnauthorizedAccessException(); } RestartAppServerResponse restartResponse; try { using (AmazonElasticBeanstalkClient client = new AmazonElasticBeanstalkClient(RegionEndpoint.EUWest1)) { RestartAppServerRequest request = new RestartAppServerRequest { EnvironmentName = environmentName, }; restartResponse = await client.RestartAppServerAsync(request); } } catch (AmazonElasticBeanstalkException ex) { return(new HttpStatusCodeResult(ex.StatusCode, ex.Message)); } return(this.RedirectToAction("Index", "Restart")); }