Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
JCLOUDS-1598: Support Metric Alert Operation (#134)
- Loading branch information
1 parent
99f2ff8
commit 83deb0efef180f75c05d291e4a03d45d59bd0bce
Showing
15 changed files
with
1,096 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,56 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.domain; | ||
|
||
import java.util.List; | ||
|
||
import org.jclouds.javax.annotation.Nullable; | ||
import org.jclouds.json.SerializedNames; | ||
|
||
import com.google.auto.value.AutoValue; | ||
|
||
@AutoValue | ||
public abstract class Criteria { | ||
|
||
@Nullable | ||
public abstract List<MetricAlertCriteria> allOf(); | ||
|
||
@Nullable | ||
public abstract String odatatype(); | ||
|
||
@SerializedNames({ "allOf", "odata.type" }) | ||
public static Criteria create(final List<MetricAlertCriteria> allOf, | ||
final String odatatype) { | ||
return builder().allOf(allOf).odatatype(odatatype).build(); | ||
} | ||
|
||
public abstract Builder toBuilder(); | ||
|
||
public static Builder builder() { | ||
return new AutoValue_Criteria.Builder(); | ||
} | ||
|
||
@AutoValue.Builder | ||
public abstract static class Builder { | ||
|
||
public abstract Builder allOf(List<MetricAlertCriteria> allOf); | ||
|
||
public abstract Builder odatatype(String odatatype); | ||
|
||
public abstract Criteria build(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,37 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.domain; | ||
|
||
import org.jclouds.json.SerializedNames; | ||
|
||
import com.google.auto.value.AutoValue; | ||
|
||
@AutoValue | ||
public abstract class DynamicThresholdFailingPeriods { | ||
|
||
public abstract int minFailingPeriodsToAlert(); | ||
|
||
public abstract int numberOfEvaluationPeriods(); | ||
|
||
@SerializedNames({ "minFailingPeriodsToAlert", "numberOfEvaluationPeriods" }) | ||
public static DynamicThresholdFailingPeriods create(final int minFailingPeriodsToAlert, | ||
final int numberOfEvaluationPeriods) { | ||
return new AutoValue_DynamicThresholdFailingPeriods(minFailingPeriodsToAlert, numberOfEvaluationPeriods); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,91 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.domain; | ||
|
||
import java.util.Map; | ||
|
||
import org.jclouds.javax.annotation.Nullable; | ||
import org.jclouds.json.SerializedNames; | ||
|
||
import com.google.auto.value.AutoValue; | ||
import com.google.common.collect.ImmutableMap; | ||
|
||
@AutoValue | ||
public abstract class MetricAlert { | ||
|
||
/** | ||
* The id of the resource | ||
*/ | ||
public abstract String id(); | ||
|
||
/** | ||
* The name of the resource | ||
*/ | ||
public abstract String name(); | ||
|
||
/** | ||
* The location of the resource | ||
*/ | ||
public abstract String location(); | ||
|
||
/** | ||
* The type of the resource | ||
*/ | ||
public abstract String type(); | ||
|
||
@Nullable | ||
public abstract Map<String, String> tags(); | ||
|
||
@Nullable | ||
public abstract MetricAlertProperties properties(); | ||
|
||
@SerializedNames({ "id", "name", "location", "type", "tags", "properties" }) | ||
public static MetricAlert create(final String id, final String name, final String location, | ||
final String type, final Map<String, String> tags, final MetricAlertProperties properties) { | ||
return builder().id(id).name(name).location(location).type(type).tags(tags).properties(properties).build(); | ||
} | ||
|
||
public abstract Builder toBuilder(); | ||
|
||
public static Builder builder() { | ||
return new AutoValue_MetricAlert.Builder(); | ||
} | ||
|
||
@AutoValue.Builder | ||
public abstract static class Builder { | ||
public abstract Builder id(String id); | ||
|
||
public abstract Builder name(String name); | ||
|
||
public abstract Builder location(String location); | ||
|
||
public abstract Builder type(String type); | ||
|
||
public abstract Builder tags(Map<String, String> tags); | ||
|
||
public abstract Builder properties(MetricAlertProperties properties); | ||
|
||
abstract Map<String, String> tags(); | ||
|
||
abstract MetricAlert autoBuild(); | ||
|
||
public MetricAlert build() { | ||
tags(tags() != null ? ImmutableMap.copyOf(tags()) : null); | ||
return autoBuild(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,38 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.domain; | ||
|
||
import org.jclouds.javax.annotation.Nullable; | ||
import org.jclouds.json.SerializedNames; | ||
|
||
import com.google.auto.value.AutoValue; | ||
|
||
@AutoValue | ||
public abstract class MetricAlertAction { | ||
@Nullable | ||
public abstract String actionGroupId(); | ||
|
||
@Nullable | ||
public abstract Object webhookProperties(); | ||
|
||
@SerializedNames({ "actionGroupId", "webhookProperties" }) | ||
public static MetricAlertAction create(final String actionGroupId, final Object webhookProperties) { | ||
return new AutoValue_MetricAlertAction(actionGroupId, webhookProperties); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,116 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 org.jclouds.azurecompute.arm.domain; | ||
|
||
import java.util.List; | ||
|
||
import org.jclouds.azurecompute.arm.util.GetEnumValue; | ||
import org.jclouds.javax.annotation.Nullable; | ||
import org.jclouds.json.SerializedNames; | ||
|
||
import com.google.auto.value.AutoValue; | ||
|
||
@AutoValue | ||
public abstract class MetricAlertCriteria { | ||
|
||
@Nullable | ||
public abstract String criterionType(); | ||
|
||
@Nullable | ||
public abstract List<MetricDimension> dimensions(); | ||
|
||
@Nullable | ||
public abstract String metricName(); | ||
|
||
@Nullable | ||
public abstract String metricNamespace(); | ||
|
||
@Nullable | ||
public abstract String name(); | ||
|
||
@Nullable | ||
public abstract Operator operator(); | ||
|
||
public abstract boolean skipMetricValidation(); | ||
|
||
public abstract int threshold(); | ||
|
||
@Nullable | ||
public abstract AggregationTypeEnum timeAggregation(); | ||
|
||
@Nullable | ||
public abstract DynamicThresholdSensitivity alertSensitivity(); | ||
|
||
@Nullable | ||
public abstract DynamicThresholdFailingPeriods failingPeriods(); | ||
|
||
@Nullable | ||
public abstract String ignoreDataBefore(); | ||
|
||
@Nullable | ||
public abstract String componentId(); | ||
|
||
public abstract int failedLocationCount(); | ||
|
||
@Nullable | ||
public abstract String webTestId(); | ||
|
||
@SerializedNames({ "criterionType", "dimensions", "metricName", "metricNamespace", "name", "operator", | ||
"skipMetricValidation", "threshold", "timeAggregation", "alertSensitivity", "failingPeriods", | ||
"ignoreDataBefore", "componentId", "failedLocationCount", "webTestId" }) | ||
public static MetricAlertCriteria create(final String criterionType, List<MetricDimension> dimensions, | ||
final String metricName, final String metricNamespace, final String name, final Operator operator, | ||
final boolean skipMetricValidation, final int threshold, final AggregationTypeEnum timeAggregation, | ||
final DynamicThresholdSensitivity alertSensitivity, final DynamicThresholdFailingPeriods failingPeriods, | ||
final String ignoreDataBefore, final String componentId, final int failedLocationCount, | ||
final String webTestId) { | ||
return new AutoValue_MetricAlertCriteria(criterionType, dimensions, metricName, metricNamespace, name, operator, | ||
skipMetricValidation, threshold, timeAggregation, alertSensitivity, failingPeriods, ignoreDataBefore, | ||
componentId, failedLocationCount, webTestId); | ||
|
||
} | ||
|
||
public enum AggregationTypeEnum { | ||
Average, Count, Maximum, Minimum, Total; | ||
public static AggregationTypeEnum fromValue(final String text) { | ||
return (AggregationTypeEnum) GetEnumValue.fromValueOrDefault(text, AggregationTypeEnum.Average); | ||
} | ||
} | ||
|
||
public enum Operator { | ||
Equals, GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual, GreaterOrLessThan; | ||
public static Operator fromValue(final String text) { | ||
return (Operator) GetEnumValue.fromValueOrDefault(text, Operator.Equals); | ||
} | ||
} | ||
|
||
public enum DynamicThresholdSensitivity { | ||
High, Low, Medium; | ||
public static DynamicThresholdSensitivity fromValue(final String text) { | ||
return (DynamicThresholdSensitivity) GetEnumValue.fromValueOrDefault(text, | ||
DynamicThresholdSensitivity.High); | ||
} | ||
} | ||
|
||
public enum DynamicThresholdOperator { | ||
GreaterOrLessThan, GreaterThan, LessThan; | ||
public static DynamicThresholdOperator fromValue(final String text) { | ||
return (DynamicThresholdOperator) GetEnumValue.fromValueOrDefault(text, | ||
DynamicThresholdOperator.GreaterOrLessThan); | ||
} | ||
} | ||
} |
Oops, something went wrong.