aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequestSource.java
blob: 0c43a3704dff6cfc5e0d7accd5b4b62e30174340 (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
// 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.time.ZonedDateTime;
import java.util.List;
import java.util.Objects;

import static com.yahoo.vespa.hosted.controller.api.integration.vcmr.ChangeRequestSource.Status.*;

/**
 * @author olaa
 */
public record ChangeRequestSource(String system,
                                  String id,
                                  String url,
                                  Status status,
                                  ZonedDateTime plannedStartTime,
                                  ZonedDateTime plannedEndTime,
                                  String category) {

    public boolean isClosed() {
        return List.of(CLOSED, CANCELED, COMPLETE).contains(status);
    }

    public enum Status {
        DRAFT,
        WAITING_FOR_APPROVAL,
        APPROVED,
        STARTED,
        COMPLETE,
        CLOSED,
        CANCELED,
        UNKNOWN_STATUS
    }

    public static class Builder {
        private String system;
        private String id;
        private String url;
        private Status status;
        private ZonedDateTime plannedStartTime;
        private ZonedDateTime plannedEndTime;
        private String category;

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

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

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

        public Builder status(Status status) {
            this.status = status;
            return this;
        }

        public Builder plannedStartTime(ZonedDateTime plannedStartTime) {
            this.plannedStartTime = plannedStartTime;
            return this;
        }

        public Builder plannedEndTime(ZonedDateTime plannedEndTime) {
            this.plannedEndTime = plannedEndTime;
            return this;
        }

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

        public ChangeRequestSource build() {
            return new ChangeRequestSource(system, id, url, status, plannedStartTime, plannedEndTime, category);
        }
    }

}