1 package org.kuali.common.devops.ci.model;
2
3 import org.kuali.common.core.build.ValidatingBuilder;
4 import org.kuali.common.core.validate.annotation.IdiotProofImmutable;
5 import org.kuali.common.devops.aws.Tags;
6 import org.kuali.common.devops.aws.Tags.Stack;
7
8 import com.amazonaws.regions.Region;
9 import com.amazonaws.regions.RegionUtils;
10
11 @IdiotProofImmutable
12 public final class CloneJenkinsStackContext {
13
14 private final Region region;
15 private final Stack srcStack;
16 private final Stack dstStack;
17 private final BackupMode mode;
18 private final String version;
19
20 private CloneJenkinsStackContext(Builder builder) {
21 this.region = builder.region;
22 this.srcStack = builder.srcStack;
23 this.dstStack = builder.dstStack;
24 this.mode = builder.mode;
25 this.version = builder.version;
26 }
27
28 public static class Builder extends ValidatingBuilder<CloneJenkinsStackContext> {
29
30 private Region region = RegionUtils.getRegion("us-west-1");
31 private Stack srcStack = Tags.Stack.TEST;
32 private Stack dstStack = Tags.Stack.PROD;
33 private BackupMode mode = BackupMode.THIN;
34 private String version = Constants.JENKINS_VERSION;
35
36 public Builder withMode(BackupMode mode) {
37 this.mode = mode;
38 return this;
39 }
40
41 public Builder withMode(String mode) {
42 return withMode(BackupMode.valueOf(mode));
43 }
44
45 public Builder withRegion(String region) {
46 this.region = RegionUtils.getRegion(region);
47 return this;
48 }
49
50 public Builder withVersion(String version) {
51 this.version = version;
52 return this;
53 }
54
55 public Builder withSrcStack(Stack srcStack) {
56 this.srcStack = srcStack;
57 return this;
58 }
59
60 public Builder withDstStack(Stack dstStack) {
61 this.dstStack = dstStack;
62 return this;
63 }
64
65 @Override
66 public CloneJenkinsStackContext build() {
67 return validate(new CloneJenkinsStackContext(this));
68 }
69 }
70
71 public Region getRegion() {
72 return region;
73 }
74
75 public Stack getSrcStack() {
76 return srcStack;
77 }
78
79 public Stack getDstStack() {
80 return dstStack;
81 }
82
83 public BackupMode getMode() {
84 return mode;
85 }
86
87 public String getVersion() {
88 return version;
89 }
90
91 }