Skip to content
Permalink
Browse files
JCLOUDS-1597: Support for Alerts (#133)
  • Loading branch information
SATYANAN-ANAND committed Feb 21, 2022
1 parent 738a01d commit 99f2ff86dae81c51834271b80a56fdac47719dfd
Showing 29 changed files with 1,936 additions and 5 deletions.
@@ -21,6 +21,7 @@

import org.jclouds.azurecompute.arm.domain.ServicePrincipal;
import org.jclouds.azurecompute.arm.features.ActivityLogAlertApi;
import org.jclouds.azurecompute.arm.features.AlertApi;
import org.jclouds.azurecompute.arm.features.AvailabilitySetApi;
import org.jclouds.azurecompute.arm.features.DeploymentApi;
import org.jclouds.azurecompute.arm.features.DiskApi;
@@ -305,4 +306,13 @@ NetworkSecurityRuleApi getNetworkSecurityRuleApi(@PathParam("resourcegroup") Str
*/
@Delegate
ActivityLogAlertApi getActivityLogAlertApi(@PathParam("resourcegroup") String resourcegroup);

/**
* Management features for Alerts.
*
* @see <a href=
* "https://docs.microsoft.com/en-us/rest/api/monitor/alertsmanagement/alerts">docs</a>
*/
@Delegate
AlertApi getAlertApi(@PathParam("resourceid") String resourceid);
}
@@ -40,6 +40,7 @@

import org.jclouds.azurecompute.arm.domain.Region;
import org.jclouds.azurecompute.arm.features.ActivityLogAlertApi;
import org.jclouds.azurecompute.arm.features.AlertApi;
import org.jclouds.azurecompute.arm.features.AvailabilitySetApi;
import org.jclouds.azurecompute.arm.features.DeploymentApi;
import org.jclouds.azurecompute.arm.features.DiskApi;
@@ -138,6 +139,7 @@ public static Properties defaultProperties() {
properties.put(API_VERSION_PREFIX + VirtualNetworkGatewayApi.class.getSimpleName(), "2018-02-01");
properties.put(API_VERSION_PREFIX + VirtualNetworkGatewayConnectionApi.class.getSimpleName(), "2018-02-01");
properties.put(API_VERSION_PREFIX + ActivityLogAlertApi.class.getSimpleName(), "2020-10-01");
properties.put(API_VERSION_PREFIX + AlertApi.class.getSimpleName(), "2019-03-01");

return properties;
}
@@ -0,0 +1,34 @@
/*
* 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 ActionStatus {

public abstract boolean isSuppressed();

@SerializedNames({ "isSuppressed" })
public static ActionStatus create(final boolean isSuppressed) {
return new AutoValue_ActionStatus(isSuppressed);

}

}
@@ -28,9 +28,8 @@ public abstract class ActivityLogAlertProperties {

@Nullable
public abstract String description();

@Nullable
public abstract Boolean enabled();

public abstract boolean enabled();

@Nullable
public abstract List<String> scopes();
@@ -42,7 +41,7 @@ public abstract class ActivityLogAlertProperties {
public abstract Actions actions();

@SerializedNames({ "description", "enabled", "scopes", "condition", "actions" })
public static ActivityLogAlertProperties create(final String description, final Boolean enabled,
public static ActivityLogAlertProperties create(final String description, final boolean enabled,
final List<String> scopes, final AlertRuleAllOfCondition condition, final Actions actions) {
return builder().description(description).enabled(enabled).scopes(scopes).condition(condition).actions(actions)
.build();
@@ -58,7 +57,7 @@ public static Builder builder() {
public abstract static class Builder {
public abstract Builder description(String description);

public abstract Builder enabled(Boolean enabled);
public abstract Builder enabled(boolean enabled);

public abstract Builder scopes(List<String> scopes);

@@ -0,0 +1,61 @@
/*
* 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 Alert {

public abstract String id();

public abstract String name();

public abstract String type();

@Nullable
public abstract AlertProperties properties();

@SerializedNames({ "id", "name", "type", "properties" })
public static Alert create(final String id, final String name, final String type,
final AlertProperties properties) {
return builder().id(id).name(name).type(type).properties(properties).build();
}

public abstract Builder toBuilder();

public static Builder builder() {
return new AutoValue_Alert.Builder();
}

@AutoValue.Builder
public abstract static class Builder {
public abstract Builder id(String id);

public abstract Builder name(String name);

public abstract Builder type(String type);

public abstract Builder properties(AlertProperties properties);

public abstract Alert build();

}
}
@@ -0,0 +1,59 @@
/*
* 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 AlertModification {

public abstract String id();

public abstract String name();

public abstract String type();

public abstract AlertModificationProperties properties();

@SerializedNames({ "id", "name", "type", "properties" })
public static AlertModification create(final String id, final String name, final String type,
AlertModificationProperties properties) {
return builder().id(id).name(name).type(type).properties(properties).build();
}

public abstract Builder toBuilder();

public static Builder builder() {
return new AutoValue_AlertModification.Builder();
}

@AutoValue.Builder
public abstract static class Builder {
public abstract Builder id(String id);

public abstract Builder name(String name);

public abstract Builder type(String type);

public abstract Builder properties(AlertModificationProperties properties);

public abstract AlertModification build();

}
}
@@ -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 org.jclouds.json.SerializedNames;

import com.google.auto.value.AutoValue;

@AutoValue
public abstract class AlertModificationEvent {

public abstract String AlertCreated();

public abstract String MonitorConditionChange();

public abstract String StateChange();

@SerializedNames({ "AlertCreated", "MonitorConditionChange", "StateChange" })
public static AlertModificationEvent create(final String AlertCreated, final String MonitorConditionChange,
final String StateChange) {
return builder().AlertCreated(AlertCreated).MonitorConditionChange(MonitorConditionChange)
.StateChange(StateChange).build();
}

public abstract Builder toBuilder();

public static Builder builder() {
return new AutoValue_AlertModificationEvent.Builder();
}

@AutoValue.Builder
public abstract static class Builder {
public abstract Builder AlertCreated(String AlertCreated);

public abstract Builder MonitorConditionChange(String MonitorConditionChange);

public abstract Builder StateChange(String StateChange);

public abstract AlertModificationEvent build();

}
}
@@ -0,0 +1,86 @@
/*
* 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.Date;

import org.jclouds.azurecompute.arm.util.GetEnumValue;
import org.jclouds.json.SerializedNames;

import com.google.auto.value.AutoValue;

@AutoValue
public abstract class AlertModificationItem {

public enum AlertModificationEvent {
AlertCreated, MonitorConditionChange, StateChange;

public static AlertModificationEvent fromValue(final String text) {
return (AlertModificationEvent) GetEnumValue.fromValueOrDefault(text, AlertModificationEvent.AlertCreated);
}
}

public abstract String comments();

public abstract String description();

public abstract AlertModificationEvent modificationEvent();

public abstract Date modifiedAt();

public abstract String modifiedBy();

public abstract String newValue();

public abstract String oldValue();

@SerializedNames({ "comments", "description", "modificationEvent", "modifiedAt", "modifiedBy", "newValue",
"oldValue" })
public static AlertModificationItem create(final String comments, final String description,
final AlertModificationEvent modificationEvent, final Date modifiedAt, final String modifiedBy,
final String newValue, final String oldValue) {
return builder().comments(comments).description(description).modificationEvent(modificationEvent)
.modifiedAt(modifiedAt).modifiedBy(modifiedBy).newValue(newValue).oldValue(oldValue).build();
}

public abstract Builder toBuilder();

public static Builder builder() {
return new AutoValue_AlertModificationItem.Builder();
}

@AutoValue.Builder
public abstract static class Builder {

public abstract Builder comments(String comments);

public abstract Builder description(String description);

public abstract Builder modificationEvent(AlertModificationEvent modificationEvent);

public abstract Builder modifiedAt(Date modifiedAt);

public abstract Builder modifiedBy(String modifiedBy);

public abstract Builder newValue(String newValue);

public abstract Builder oldValue(String oldValue);

public abstract AlertModificationItem build();

}
}

0 comments on commit 99f2ff8

Please sign in to comment.