aboutsummaryrefslogtreecommitdiffstats
path: root/controller-api
diff options
context:
space:
mode:
authorOla Aunrønning <olaa@verizonmedia.com>2021-03-15 14:41:26 +0100
committerGitHub <noreply@github.com>2021-03-15 14:41:26 +0100
commit7fb97bb3b0ecc806325d85ad064a341163a91637 (patch)
tree34feb65601942173f47e331b8cb3d6e5ac23fc14 /controller-api
parent04c74ec36ee6546b4670be6311206d965cf9f2d5 (diff)
parent8fd9ef1bd6fd6220413668ecb621596ad3908744 (diff)
Merge pull request #16954 from vespa-engine/olaa/change-request
Add ChangeRequestMaintainer
Diffstat (limited to 'controller-api')
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ServiceRegistry.java3
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequest.java139
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequestClient.java15
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequestSource.java137
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/NoopChangeRequestClient.java19
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/package-info.java5
6 files changed, 318 insertions, 0 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ServiceRegistry.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ServiceRegistry.java
index b2fd4a5d76c..98591ba41e2 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ServiceRegistry.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/ServiceRegistry.java
@@ -25,6 +25,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.resource.CostReportCons
import com.yahoo.vespa.hosted.controller.api.integration.resource.MeteringClient;
import com.yahoo.vespa.hosted.controller.api.integration.routing.GlobalRoutingService;
import com.yahoo.vespa.hosted.controller.api.integration.secrets.TenantSecretService;
+import com.yahoo.vespa.hosted.controller.api.integration.vcmr.ChangeRequestClient;
import com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneRegistry;
import java.time.Clock;
@@ -90,4 +91,6 @@ public interface ServiceRegistry {
TenantSecretService tenantSecretService();
ArchiveService archiveService();
+
+ ChangeRequestClient changeRequestClient();
}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequest.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequest.java
new file mode 100644
index 00000000000..a56f96955de
--- /dev/null
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequest.java
@@ -0,0 +1,139 @@
+// Copyright Verizon Media. 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 boolean isApproved;
+ private final Impact impact;
+
+ private ChangeRequest(String id, ChangeRequestSource changeRequestSource, List<String> impactedSwitches, List<String> impactedHosts, boolean isApproved, Impact impact) {
+ this.id = Objects.requireNonNull(id);
+ this.changeRequestSource = Objects.requireNonNull(changeRequestSource);
+ this.impactedSwitches = Objects.requireNonNull(impactedSwitches);
+ this.impactedHosts = Objects.requireNonNull(impactedHosts);
+ this.isApproved = Objects.requireNonNull(isApproved);
+ 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 boolean isApproved() {
+ return isApproved;
+ }
+
+ public Impact getImpact() {
+ return impact;
+ }
+
+ @Override
+ public String toString() {
+ return "ChangeRequest{" +
+ "id='" + id + '\'' +
+ ", changeRequestSource=" + changeRequestSource +
+ ", impactedSwitches=" + impactedSwitches +
+ ", impactedHosts=" + impactedHosts +
+ ", isApproved=" + isApproved +
+ ", 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 isApproved == that.isApproved &&
+ 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, isApproved, impact);
+ }
+
+ public static class Builder {
+ private String id;
+ private ChangeRequestSource changeRequestSource;
+ private List<String> impactedSwitches;
+ private List<String> impactedHosts;
+ private boolean isApproved;
+ 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 isApproved(boolean isApproved) {
+ this.isApproved = isApproved;
+ return this;
+ }
+
+ public Builder impact(Impact impact) {
+ this.impact = impact;
+ return this;
+ }
+
+ public ChangeRequest build() {
+ return new ChangeRequest(id, changeRequestSource, impactedSwitches, impactedHosts, isApproved, impact);
+ }
+
+ public String getId() {
+ return this.id;
+ }
+ }
+
+ public enum Impact {
+ NONE,
+ LOW,
+ MODERATE,
+ HIGH,
+ VERY_HIGH,
+ UNKNOWN
+ }
+
+}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequestClient.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequestClient.java
new file mode 100644
index 00000000000..e8ff768927f
--- /dev/null
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequestClient.java
@@ -0,0 +1,15 @@
+// Copyright Verizon Media. 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;
+
+/**
+ * @author olaa
+ */
+public interface ChangeRequestClient {
+
+ List<ChangeRequest> getUpcomingChangeRequests();
+
+ void approveChangeRequests(List<ChangeRequest> changeRequests);
+
+}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequestSource.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequestSource.java
new file mode 100644
index 00000000000..63f6c256766
--- /dev/null
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/ChangeRequestSource.java
@@ -0,0 +1,137 @@
+// Copyright Verizon Media. 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.Objects;
+
+/**
+ * @author olaa
+ */
+public class ChangeRequestSource {
+
+ private final String system;
+ private final String id;
+ private final Status status;
+ private final String url;
+ private final ZonedDateTime plannedStartTime;
+ private final ZonedDateTime plannedEndTime;
+
+
+ private ChangeRequestSource(String system, String id, String url, Status status, ZonedDateTime plannedStartTime, ZonedDateTime plannedEndTime) {
+ this.system = Objects.requireNonNull(system);
+ this.id = Objects.requireNonNull(id);
+ this.url = Objects.requireNonNull(url);
+ this.status = Objects.requireNonNull(status);
+ this.plannedStartTime = Objects.requireNonNull(plannedStartTime);
+ this.plannedEndTime = Objects.requireNonNull(plannedEndTime);
+ }
+
+ public String getSystem() {
+ return system;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public Status getStatus() {
+ return status;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public ZonedDateTime getPlannedStartTime() {
+ return plannedStartTime;
+ }
+
+ public ZonedDateTime getPlannedEndTime() {
+ return plannedEndTime;
+ }
+
+ @Override
+ public String toString() {
+ return "ChangeRequestSource{" +
+ "system='" + system + '\'' +
+ ", id='" + id + '\'' +
+ ", status=" + status +
+ ", url='" + url + '\'' +
+ ", plannedStartTime=" + plannedStartTime +
+ ", plannedEndTime=" + plannedEndTime +
+ '}';
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ChangeRequestSource that = (ChangeRequestSource) o;
+ return Objects.equals(system, that.system) &&
+ Objects.equals(id, that.id) &&
+ status == that.status &&
+ Objects.equals(url, that.url) &&
+ Objects.equals(plannedStartTime, that.plannedStartTime) &&
+ Objects.equals(plannedEndTime, that.plannedEndTime);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(system, id, status, url, plannedStartTime, plannedEndTime);
+ }
+
+ 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;
+
+ 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 ChangeRequestSource build() {
+ return new ChangeRequestSource(system, id, url, status, plannedStartTime, plannedEndTime);
+ }
+ }
+
+}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/NoopChangeRequestClient.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/NoopChangeRequestClient.java
new file mode 100644
index 00000000000..d548620b062
--- /dev/null
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/NoopChangeRequestClient.java
@@ -0,0 +1,19 @@
+// Copyright Verizon Media. 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;
+
+/**
+ * @author olaa
+ */
+public class NoopChangeRequestClient implements ChangeRequestClient {
+
+ @Override
+ public List<ChangeRequest> getUpcomingChangeRequests() {
+ return List.of();
+ }
+
+ @Override
+ public void approveChangeRequests(List<ChangeRequest> changeRequests) {}
+
+}
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/package-info.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/package-info.java
new file mode 100644
index 00000000000..8962d8e79f4
--- /dev/null
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/vcmr/package-info.java
@@ -0,0 +1,5 @@
+// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+@ExportPackage
+package com.yahoo.vespa.hosted.controller.api.integration.vcmr;
+
+import com.yahoo.osgi.annotation.ExportPackage; \ No newline at end of file