View Javadoc
1   /*
2    * Copyright (c) 2016 ingenieux Labs
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package br.com.ingenieux.mojo.beanstalk.cmd.env.terminate;
18  
19  import com.amazonaws.services.elasticbeanstalk.model.TerminateEnvironmentRequest;
20  import com.amazonaws.services.elasticbeanstalk.model.TerminateEnvironmentResult;
21  
22  import org.apache.maven.plugin.AbstractMojoExecutionException;
23  
24  import br.com.ingenieux.mojo.beanstalk.AbstractBeanstalkMojo;
25  import br.com.ingenieux.mojo.beanstalk.cmd.BaseCommand;
26  
27  public class TerminateEnvironmentCommand extends BaseCommand<TerminateEnvironmentContext, TerminateEnvironmentResult> {
28  
29    /**
30     * Constructor
31     *
32     * @param parentMojo parent mojo
33     */
34    public TerminateEnvironmentCommand(AbstractBeanstalkMojo parentMojo) throws AbstractMojoExecutionException {
35      super(parentMojo);
36    }
37  
38    @Override
39    protected TerminateEnvironmentResult executeInternal(TerminateEnvironmentContext context) throws Exception {
40      TerminateEnvironmentRequest req =
41          new TerminateEnvironmentRequest()
42              .withEnvironmentId(context.environmentId)
43              .withEnvironmentName(context.environmentName)
44              .withTerminateResources(context.terminateResources);
45  
46      return service.terminateEnvironment(req);
47    }
48  }