aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequest.java
blob: 468129da24fdf3cb91d27db44f57cac0fd99dfa5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.api.integration.vcmr;

import java.util.List;
import java.util.Objects;

/**
 * @author olaa
 */
public class ChangeRequest {

    private final String id;
    private final ChangeRequestSource changeRequestSource;
    private final List<String> impactedSwitches;
    private final List<String> impactedHosts;
    private final Approval approval;
    private final Impact impact;

    public ChangeRequest(String id, ChangeRequestSource changeRequestSource, List<String> impactedSwitches, List<String> impactedHosts, Approval approval, Impact impact) {
        this.id = Objects.requireNonNull(id);
        this.changeRequestSource = Objects.requireNonNull(changeRequestSource);
        this.impactedSwitches = Objects.requireNonNull(impactedSwitches);
        this.impactedHosts = Objects.requireNonNull(impactedHosts);
        this.approval = Objects.requireNonNull(approval);
        this.impact = Objects.requireNonNull(impact);
    }

    public String getId() {
        return id;
    }

    public ChangeRequestSource getChangeRequestSource() {
        return changeRequestSource;
    }

    public List<String> getImpactedSwitches() {
        return impactedSwitches;
    }

    public List<String> getImpactedHosts() {
        return impactedHosts;
    }

    public Approval getApproval() {
        return approval;
    }

    public Impact getImpact() {
        return impact;
    }

    @Override
    public String toString() {
        return "ChangeRequest{" +
                "id='" + id + '\'' +
                ", changeRequestSource=" + changeRequestSource +
                ", impactedSwitches=" + impactedSwitches +
                ", impactedHosts=" + impactedHosts +
                ", approval=" + approval +
                ", impact=" + impact +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ChangeRequest that = (ChangeRequest) o;
        return approval == that.approval &&
                Objects.equals(id, that.id) &&
                Objects.equals(changeRequestSource, that.changeRequestSource) &&
                Objects.equals(impactedSwitches, that.impactedSwitches) &&
                Objects.equals(impactedHosts, that.impactedHosts) &&
                impact == that.impact;
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, changeRequestSource, impactedSwitches, impactedHosts, approval, impact);
    }

    public static class Builder {
        private String id;
        private ChangeRequestSource changeRequestSource;
        private List<String> impactedSwitches;
        private List<String> impactedHosts;
        private Approval approval = Approval.OTHER;
        private Impact impact;


        public Builder id(String id) {
            this.id = id;
            return this;
        }

        public Builder changeRequestSource(ChangeRequestSource changeRequestSource) {
            this.changeRequestSource = changeRequestSource;
            return this;
        }

        public Builder impactedSwitches(List<String> impactedSwitches) {
            this.impactedSwitches = impactedSwitches;
            return this;
        }

        public Builder impactedHosts(List<String> impactedHosts) {
            this.impactedHosts = impactedHosts;
            return this;
        }

        public Builder approval(Approval approval) {
            this.approval = approval;
            return this;
        }

        public Builder impact(Impact impact) {
            this.impact = impact;
            return this;
        }

        public ChangeRequest build() {
            return new ChangeRequest(id, changeRequestSource, impactedSwitches, impactedHosts, approval, impact);
        }

        public String getId() {
            return this.id;
        }
    }

    public enum Impact {
        NONE,
        LOW,
        MODERATE,
        HIGH,
        VERY_HIGH,
        UNKNOWN
    }

    public enum Approval {
        REQUESTED,
        APPROVED,
        REJECTED,
        OTHER
    }

}