1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package br.com.ingenieux.mojo.beanstalk.env;
18
19 import com.amazonaws.services.elasticbeanstalk.model.ConfigurationOptionSetting;
20 import com.amazonaws.services.elasticbeanstalk.model.OptionSpecification;
21 import com.amazonaws.services.elasticbeanstalk.model.UpdateEnvironmentRequest;
22
23 import org.apache.maven.plugin.MojoExecutionException;
24 import org.apache.maven.plugin.MojoFailureException;
25 import org.apache.maven.plugins.annotations.Mojo;
26 import org.apache.maven.plugins.annotations.Parameter;
27
28 import br.com.ingenieux.mojo.beanstalk.AbstractNeedsEnvironmentMojo;
29
30
31
32
33
34
35
36
37
38 @Mojo(name = "update-environment-options", requiresDirectInvocation = true)
39 public class UpdateEnvironmentOptionsMojo extends AbstractNeedsEnvironmentMojo {
40
41
42
43
44 @Parameter ConfigurationOptionSetting[] optionSettings;
45
46
47
48
49 @Parameter OptionSpecification[] optionsToRemove;
50
51
52
53
54 @Parameter(property = "beanstalk.environmentDescription", defaultValue = "default")
55 String environmentDescription;
56
57
58
59 @Parameter(property = "beanstalk.versionLabel")
60 String versionLabel;
61
62
63
64
65
66
67
68 @Parameter(property = "beanstalk.templateName")
69 String templateName;
70
71
72
73 @Parameter(property = "beanstalk.whatToSet", defaultValue = "versionLabel", required = true)
74 WhatToSet whatToSet;
75
76 protected Object executeInternal() throws MojoExecutionException, MojoFailureException {
77 UpdateEnvironmentRequest req = new UpdateEnvironmentRequest();
78
79 req.setEnvironmentId(curEnv.getEnvironmentId());
80 req.setEnvironmentName(curEnv.getEnvironmentName());
81
82 if (WhatToSet.versionLabel.equals(whatToSet)) {
83 req.setVersionLabel(versionLabel);
84 } else if (WhatToSet.description.equals(whatToSet)) {
85 req.setDescription(environmentDescription);
86 } else if (WhatToSet.optionSettings.equals(whatToSet)) {
87 req.setOptionSettings(getOptionSettings(optionSettings));
88 } else if (WhatToSet.templateName.equals(whatToSet)) {
89 req.setTemplateName(lookupTemplateName(applicationName, templateName));
90 } else if (WhatToSet.optionsToRemove.equals(whatToSet)) {
91 req.setOptionsToRemove(getOptionsToRemove(optionsToRemove));
92 }
93
94 return getService().updateEnvironment(req);
95 }
96
97 public enum WhatToSet {
98 description,
99 optionSettings,
100 templateName,
101 versionLabel,
102 optionsToRemove
103 }
104 }