Skip to content
This repository has been archived by the owner on Jul 29, 2021. It is now read-only.

Commit

Permalink
feat: allows to send an alert when the HC status changes
Browse files Browse the repository at this point in the history
  • Loading branch information
aelamrani authored and brasseld committed Nov 25, 2018
1 parent 987b0c8 commit cc020f8
Show file tree
Hide file tree
Showing 3 changed files with 294 additions and 0 deletions.
@@ -0,0 +1,31 @@
/**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.repository.management.api;

import io.gravitee.repository.exceptions.TechnicalException;
import io.gravitee.repository.management.model.Alert;

import java.util.List;
import java.util.Set;

/**
* @author Azize ELAMRANI (azize.elamrani at graviteesource.com)
* @author GraviteeSource Team
*/
public interface AlertRepository extends CrudRepository<Alert, String>{
Set<Alert> findAll() throws TechnicalException;
List<Alert> findByReference(String referenceType, String referenceId) throws TechnicalException;
}
186 changes: 186 additions & 0 deletions src/main/java/io/gravitee/repository/management/model/Alert.java
@@ -0,0 +1,186 @@
/**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.repository.management.model;

import java.util.Date;
import java.util.Objects;

/**
* @author Azize ELAMRANI (azize.elamrani at graviteesource.com)
* @author GraviteeSource Team
*/
public class Alert {

private String id;
private String name;
private String description;
private String referenceType;
private String referenceId;
private String type;
private String metricType;
private String metric;
private String thresholdType;
private Double threshold;
private String plan;
private boolean enabled;
private Date createdAt;
private Date updatedAt;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public String getReferenceType() {
return referenceType;
}

public void setReferenceType(String referenceType) {
this.referenceType = referenceType;
}

public String getReferenceId() {
return referenceId;
}

public void setReferenceId(String referenceId) {
this.referenceId = referenceId;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getMetricType() {
return metricType;
}

public void setMetricType(String metricType) {
this.metricType = metricType;
}

public String getMetric() {
return metric;
}

public void setMetric(String metric) {
this.metric = metric;
}

public String getThresholdType() {
return thresholdType;
}

public void setThresholdType(String thresholdType) {
this.thresholdType = thresholdType;
}

public Double getThreshold() {
return threshold;
}

public void setThreshold(Double threshold) {
this.threshold = threshold;
}

public String getPlan() {
return plan;
}

public void setPlan(String plan) {
this.plan = plan;
}

public boolean isEnabled() {
return enabled;
}

public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public Date getCreatedAt() {
return createdAt;
}

public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}

public Date getUpdatedAt() {
return updatedAt;
}

public void setUpdatedAt(Date updatedAt) {
this.updatedAt = updatedAt;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Alert)) return false;
Alert alert = (Alert) o;
return Objects.equals(id, alert.id);
}

@Override
public int hashCode() {
return Objects.hash(id);
}

@Override
public String toString() {
return "Alert{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", description='" + description + '\'' +
", referenceType='" + referenceType + '\'' +
", referenceId='" + referenceId + '\'' +
", type='" + type + '\'' +
", metricType='" + metricType + '\'' +
", metric='" + metric + '\'' +
", thresholdType='" + thresholdType + '\'' +
", threshold=" + threshold +
", plan='" + plan + '\'' +
", enabled=" + enabled +
", createdAt=" + createdAt +
", updatedAt=" + updatedAt +
'}';
}
}
@@ -0,0 +1,77 @@
/**
* Copyright (C) 2015 The Gravitee team (http://gravitee.io)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.gravitee.repository.management.model;

import java.util.Objects;

/**
* @author Azize ELAMRANI (azize.elamrani at graviteesource.com)
* @author GraviteeSource Team
*/
public class AlertCondition {

private String metric;
private String threshold;
private int value;

public String getMetric() {
return metric;
}

public void setMetric(String metric) {
this.metric = metric;
}

public String getThreshold() {
return threshold;
}

public void setThreshold(String threshold) {
this.threshold = threshold;
}

public int getValue() {
return value;
}

public void setValue(int value) {
this.value = value;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof AlertCondition)) return false;
AlertCondition that = (AlertCondition) o;
return value == that.value &&
Objects.equals(metric, that.metric) &&
Objects.equals(threshold, that.threshold);
}

@Override
public int hashCode() {
return Objects.hash(metric, threshold, value);
}

@Override
public String toString() {
return "AlertCondition{" +
"metric='" + metric + '\'' +
", threshold='" + threshold + '\'' +
", value=" + value +
'}';
}
}

0 comments on commit cc020f8

Please sign in to comment.