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.swap;
18  
19  import com.amazonaws.services.elasticbeanstalk.model.SwapEnvironmentCNAMEsRequest;
20  
21  import org.apache.maven.plugin.AbstractMojoExecutionException;
22  
23  import br.com.ingenieux.mojo.beanstalk.AbstractBeanstalkMojo;
24  import br.com.ingenieux.mojo.beanstalk.cmd.BaseCommand;
25  
26  public class SwapCNamesCommand extends BaseCommand<SwapCNamesContext, Object> {
27  
28    /**
29     * Constructor
30     *
31     * @param parentMojo parent mojo
32     */
33    public SwapCNamesCommand(AbstractBeanstalkMojo parentMojo) throws AbstractMojoExecutionException {
34      super(parentMojo);
35    }
36  
37    @Override
38    protected Object executeInternal(SwapCNamesContext context) throws Exception {
39      SwapEnvironmentCNAMEsRequest request = new SwapEnvironmentCNAMEsRequest();
40  
41      request.setSourceEnvironmentName(context.getSourceEnvironmentName());
42  
43      request.setSourceEnvironmentId(context.getSourceEnvironmentId());
44  
45      request.setDestinationEnvironmentName(context.getDestinationEnvironmentName());
46  
47      request.setDestinationEnvironmentId(context.getDestinationEnvironmentId());
48  
49      service.swapEnvironmentCNAMEs(request);
50  
51      return request;
52    }
53  }