diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeApi.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeApi.java
index 85d68cacf6..8bced3ecc7 100644
--- a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeApi.java
+++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeApi.java
@@ -21,6 +21,7 @@ import javax.ws.rs.PathParam;
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 @@ public interface AzureComputeApi extends Closeable {
*/
@Delegate
ActivityLogAlertApi getActivityLogAlertApi(@PathParam("resourcegroup") String resourcegroup);
+
+ /**
+ * Management features for Alerts.
+ *
+ * @see docs
+ */
+ @Delegate
+ AlertApi getAlertApi(@PathParam("resourceid") String resourceid);
}
diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java
index 5dbef36c74..3bb32e2940 100644
--- a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java
+++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/AzureComputeProviderMetadata.java
@@ -40,6 +40,7 @@ import java.util.Properties;
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 class AzureComputeProviderMetadata extends BaseProviderMetadata {
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;
}
diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ActionStatus.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ActionStatus.java
new file mode 100644
index 0000000000..d892800e38
--- /dev/null
+++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ActionStatus.java
@@ -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);
+
+ }
+
+}
diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ActivityLogAlertProperties.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ActivityLogAlertProperties.java
index 6517d8cdd5..33de273c12 100644
--- a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ActivityLogAlertProperties.java
+++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ActivityLogAlertProperties.java
@@ -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 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 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 abstract class ActivityLogAlertProperties {
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 scopes);
diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Alert.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Alert.java
new file mode 100644
index 0000000000..572825db91
--- /dev/null
+++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Alert.java
@@ -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();
+
+ }
+}
diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertModification.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertModification.java
new file mode 100644
index 0000000000..3334127d68
--- /dev/null
+++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertModification.java
@@ -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();
+
+ }
+}
diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertModificationEvent.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertModificationEvent.java
new file mode 100644
index 0000000000..77f5b368a8
--- /dev/null
+++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertModificationEvent.java
@@ -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();
+
+ }
+}
diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertModificationItem.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertModificationItem.java
new file mode 100644
index 0000000000..5c9524f8f9
--- /dev/null
+++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertModificationItem.java
@@ -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();
+
+ }
+}
diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertModificationProperties.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertModificationProperties.java
new file mode 100644
index 0000000000..1322ba26b3
--- /dev/null
+++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertModificationProperties.java
@@ -0,0 +1,52 @@
+/*
+ * 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.json.SerializedNames;
+
+import com.google.auto.value.AutoValue;
+
+@AutoValue
+public abstract class AlertModificationProperties {
+
+ public abstract String alertId();
+
+ public abstract List modifications();
+
+ @SerializedNames({ "alertId", "modifications" })
+ public static AlertModificationProperties create(final String alertId, List modifications) {
+ return builder().alertId(alertId).modifications(modifications).build();
+ }
+
+ public abstract Builder toBuilder();
+
+ public static Builder builder() {
+ return new AutoValue_AlertModificationProperties.Builder();
+ }
+
+ @AutoValue.Builder
+ public abstract static class Builder {
+ public abstract Builder alertId(String alertId);
+
+ public abstract Builder modifications(List modifications);
+
+ public abstract AlertModificationProperties build();
+
+ }
+}
diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertProperties.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertProperties.java
new file mode 100644
index 0000000000..182da0fe2a
--- /dev/null
+++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertProperties.java
@@ -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.domain.JsonBall;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
+
+import com.google.auto.value.AutoValue;
+
+@AutoValue
+public abstract class AlertProperties {
+
+ @Nullable
+ public abstract JsonBall context();
+
+ @Nullable
+ public abstract JsonBall egressConfig();
+
+ @Nullable
+ public abstract Essentials essentials();
+
+ @SerializedNames({ "context", "egressConfig", "essentials" })
+ public static AlertProperties create(final JsonBall context, final JsonBall egressConfig, final Essentials essentials) {
+ return builder().context(context).egressConfig(egressConfig).essentials(essentials).build();
+ }
+
+ public abstract Builder toBuilder();
+
+ public static Builder builder() {
+ return new AutoValue_AlertProperties.Builder();
+ }
+
+ @AutoValue.Builder
+ public abstract static class Builder {
+ public abstract Builder context(JsonBall context);
+
+ public abstract Builder egressConfig(JsonBall egressConfig);
+
+ public abstract Builder essentials(Essentials essentials);
+
+ public abstract AlertProperties build();
+
+ }
+}
diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertSummary.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertSummary.java
new file mode 100644
index 0000000000..59b50e250d
--- /dev/null
+++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertSummary.java
@@ -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 AlertSummary {
+
+ public abstract String id();
+
+ public abstract String name();
+
+ public abstract String type();
+
+ public abstract AlertSummaryGroup properties();
+
+ @SerializedNames({ "id", "name", "type", "properties" })
+ public static AlertSummary create(final String id, final String name, final String type,
+ final AlertSummaryGroup properties) {
+ return builder().id(id).name(name).type(type).properties(properties).build();
+ }
+
+ public abstract Builder toBuilder();
+
+ public static Builder builder() {
+ return new AutoValue_AlertSummary.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(AlertSummaryGroup properties);
+
+ public abstract AlertSummary build();
+
+ }
+}
diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertSummaryGroup.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertSummaryGroup.java
new file mode 100644
index 0000000000..3a6cba196c
--- /dev/null
+++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertSummaryGroup.java
@@ -0,0 +1,64 @@
+/*
+ * 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 AlertSummaryGroup {
+
+ public abstract String groupedby();
+
+ @Nullable
+ public abstract Integer smartGroupsCount();
+
+ public abstract int total();
+
+ @Nullable
+ public abstract List values();
+
+ @SerializedNames({ "groupedby", "smartGroupsCount", "total", "values" })
+ public static AlertSummaryGroup create(final String groupedby, final Integer smartGroupsCount, final int total,
+ final List values) {
+ return builder().groupedby(groupedby).smartGroupsCount(smartGroupsCount).total(total).values(values).build();
+ }
+
+ public abstract Builder toBuilder();
+
+ public static Builder builder() {
+ return new AutoValue_AlertSummaryGroup.Builder();
+ }
+
+ @AutoValue.Builder
+ public abstract static class Builder {
+ public abstract Builder groupedby(String groupedby);
+
+ public abstract Builder smartGroupsCount(Integer smartGroupsCount);
+
+ public abstract Builder total(int total);
+
+ public abstract Builder values(List values);
+
+ public abstract AlertSummaryGroup build();
+
+ }
+}
diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertSummaryGroupItem.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertSummaryGroupItem.java
new file mode 100644
index 0000000000..840ced39cc
--- /dev/null
+++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertSummaryGroupItem.java
@@ -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.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
+
+import com.google.auto.value.AutoValue;
+
+@AutoValue
+public abstract class AlertSummaryGroupItem {
+
+ @Nullable
+ public abstract String groupedby();
+
+ public abstract String name();
+
+ public abstract int count();
+
+ @SerializedNames({ "groupedby", "name", "count" })
+ public static AlertSummaryGroupItem create(final String groupedby, final String name, final int count) {
+ return builder().groupedby(groupedby).name(name).count(count).build();
+ }
+
+ public abstract Builder toBuilder();
+
+ public static Builder builder() {
+ return new AutoValue_AlertSummaryGroupItem.Builder();
+ }
+
+ @AutoValue.Builder
+ public abstract static class Builder {
+ public abstract Builder groupedby(String groupedby);
+
+ public abstract Builder name(String name);
+
+ public abstract Builder count(int count);
+
+ public abstract AlertSummaryGroupItem build();
+
+ }
+}
diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Essentials.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Essentials.java
new file mode 100644
index 0000000000..93c8143189
--- /dev/null
+++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Essentials.java
@@ -0,0 +1,106 @@
+/*
+ * 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.javax.annotation.Nullable;
+import org.jclouds.json.SerializedNames;
+
+import com.google.auto.value.AutoValue;
+
+@AutoValue
+public abstract class Essentials {
+
+ public enum AlertState {
+ New, Acknowledged, Closed;
+
+ public static AlertState fromValue(final String text) {
+ return (AlertState) GetEnumValue.fromValueOrDefault(text, AlertState.New);
+ }
+ }
+
+ public enum MonitorCondition {
+ Fired, Resloved;
+
+ public static MonitorCondition fromValue(final String text) {
+ return (MonitorCondition) GetEnumValue.fromValueOrDefault(text, MonitorCondition.Fired);
+ }
+ }
+
+ @Nullable
+ public abstract ActionStatus actionStatus();
+
+ @Nullable
+ public abstract String alertRule();
+
+ @Nullable
+ public abstract Date lastModifiedDateTime();
+
+ @Nullable
+ public abstract String lastModifiedUserName();
+
+ @Nullable
+ public abstract String sourceCreatedId();
+
+ @Nullable
+ public abstract Date startDateTime();
+
+ @Nullable
+ public abstract String targetResource();
+
+ @Nullable
+ public abstract String targetResourceGroup();
+
+ @Nullable
+ public abstract String targetResourceName();
+
+ @Nullable
+ public abstract String targetResourceType();
+
+ @Nullable
+ public abstract AlertState alertState();
+
+ @Nullable
+ public abstract MonitorCondition monitorCondition();
+
+ @Nullable
+ public abstract String monitorService();
+
+ @Nullable
+ public abstract String severity();
+
+ @Nullable
+ public abstract String signalType();
+
+ @SerializedNames({ "actionStatus", "alertRule", "lastModifiedDateTime", "lastModifiedUserName", "sourceCreatedId",
+ "startDateTime", "targetResource", "targetResourceGroup", "targetResourceName", "targetResourceType",
+ "alertState", "monitorCondition", "monitorService", "severity", "signalType" })
+ public static Essentials create(final ActionStatus actionStatus, final String alertRule,
+ final Date lastModifiedDateTime, final String lastModifiedUserName, final String sourceCreatedId,
+ final Date startDateTime, final String targetResource, final String targetResourceGroup,
+ final String targetResourceName, final String targetResourceType, final AlertState alertState,
+ final MonitorCondition monitorCondition, final String monitorService, final String severity,
+ final String signalType) {
+ return new AutoValue_Essentials(actionStatus, alertRule, lastModifiedDateTime, lastModifiedUserName,
+ sourceCreatedId, startDateTime, targetResource, targetResourceGroup, targetResourceName,
+ targetResourceType, alertState, monitorCondition, monitorService, severity, signalType);
+
+ }
+
+}
diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/AlertApi.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/AlertApi.java
new file mode 100644
index 0000000000..33c987aae2
--- /dev/null
+++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/AlertApi.java
@@ -0,0 +1,85 @@
+/*
+ * 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.features;
+
+import java.util.List;
+
+import javax.inject.Named;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
+import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.azurecompute.arm.domain.Alert;
+import org.jclouds.azurecompute.arm.domain.AlertModification;
+import org.jclouds.azurecompute.arm.domain.AlertSummary;
+import org.jclouds.azurecompute.arm.filters.ApiVersionFilter;
+import org.jclouds.azurecompute.arm.options.AlertRequestOptions;
+import org.jclouds.javax.annotation.Nullable;
+import org.jclouds.oauth.v2.filters.OAuthFilter;
+import org.jclouds.rest.annotations.Fallback;
+import org.jclouds.rest.annotations.RequestFilters;
+import org.jclouds.rest.annotations.SelectJson;
+
+/**
+ * This Azure Resource Manager API provides all the alerts available for a given
+ * resource
+ *
+ *
+ * @see docs
+ */
+@Path("/{resourceid}")
+@RequestFilters({ OAuthFilter.class, ApiVersionFilter.class })
+@Consumes(MediaType.APPLICATION_JSON)
+public interface AlertApi {
+ @Named("alerts:getAll")
+ @Path("/providers/Microsoft.AlertsManagement/alerts")
+ @GET
+ @SelectJson("value")
+ @Fallback(EmptyListOnNotFoundOr404.class)
+ List list(@Nullable AlertRequestOptions... getAllOptions);
+
+ @Named("alerts:getbyid")
+ @Path("/providers/Microsoft.AlertsManagement/alerts/{alertId}")
+ @GET
+ @Fallback(NullOnNotFoundOr404.class)
+ Alert get(@PathParam("alertId") String alertId);
+
+ @Named("alerts:changestate")
+ @Path("/providers/Microsoft.AlertsManagement/alerts/{alertId}/changestate")
+ @POST
+ @Fallback(NullOnNotFoundOr404.class)
+ Alert changeState(@PathParam("alertId") String alertId, @QueryParam("newState") String newState);
+
+ @Named("alerts:history")
+ @Path("/providers/Microsoft.AlertsManagement/alerts/{alertId}/history")
+ @GET
+ @Fallback(NullOnNotFoundOr404.class)
+ AlertModification getHistory(@PathParam("alertId") String alertId);
+
+ @Named("alerts:summary")
+ @Path("providers/Microsoft.AlertsManagement/alertsSummary")
+ @GET
+ @Fallback(NullOnNotFoundOr404.class)
+ AlertSummary getSummary(AlertRequestOptions... getSummaryOptions);
+}
diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/options/AlertRequestOptions.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/options/AlertRequestOptions.java
new file mode 100644
index 0000000000..34a70204b3
--- /dev/null
+++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/options/AlertRequestOptions.java
@@ -0,0 +1,268 @@
+/*
+ * 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.options;
+
+import static com.google.common.base.Preconditions.checkState;
+
+import static org.jclouds.azurecompute.arm.reference.AlertQueryParams.TARGET_RESOURCE;
+import static org.jclouds.azurecompute.arm.reference.AlertQueryParams.TARGET_RESOURCE_GROUP;
+import static org.jclouds.azurecompute.arm.reference.AlertQueryParams.TARGET_RESOURCE_TYPE;
+import static org.jclouds.azurecompute.arm.reference.AlertQueryParams.MONITOR_SERVICE;
+import static org.jclouds.azurecompute.arm.reference.AlertQueryParams.MONITOR_CONDITION;
+import static org.jclouds.azurecompute.arm.reference.AlertQueryParams.SERVERITY;
+import static org.jclouds.azurecompute.arm.reference.AlertQueryParams.ALERT_RULE;
+import static org.jclouds.azurecompute.arm.reference.AlertQueryParams.ALERT_STATE;
+import static org.jclouds.azurecompute.arm.reference.AlertQueryParams.SMART_GROUP_ID;
+import static org.jclouds.azurecompute.arm.reference.AlertQueryParams.INCLUDE_CONTEXT;
+import static org.jclouds.azurecompute.arm.reference.AlertQueryParams.INCLUDE_EGRESS_CONFIG;
+import static org.jclouds.azurecompute.arm.reference.AlertQueryParams.PAGE_COUNT;
+import static org.jclouds.azurecompute.arm.reference.AlertQueryParams.SORT_BY;
+import static org.jclouds.azurecompute.arm.reference.AlertQueryParams.SORT_ORDER;
+
+import static org.jclouds.azurecompute.arm.reference.AlertQueryParams.SELECT;
+import static org.jclouds.azurecompute.arm.reference.AlertQueryParams.TIME_RANGE;
+import static org.jclouds.azurecompute.arm.reference.AlertQueryParams.CUSTOM_TIME_RANGE;
+import static org.jclouds.azurecompute.arm.reference.AlertQueryParams.GROUP_BY;
+import static org.jclouds.azurecompute.arm.reference.AlertQueryParams.INCLUDE_SMART_GROUPS_COUNT;
+
+import org.jclouds.http.options.BaseHttpRequestOptions;
+
+public class AlertRequestOptions extends BaseHttpRequestOptions {
+
+ public static final AlertRequestOptions NONE = new AlertRequestOptions();
+
+ public AlertRequestOptions withTargetResource(String targetResource) {
+ checkState(!queryParameters.containsKey(TARGET_RESOURCE), "Can't have duplicate parameter of targetResource");
+ queryParameters.put(TARGET_RESOURCE, targetResource);
+ return this;
+ }
+
+ public AlertRequestOptions withTargetResourceGroup(String targetResourceGroup) {
+ checkState(!queryParameters.containsKey(TARGET_RESOURCE_GROUP),
+ "Can't have duplicate parameter of targetResourceGroup");
+ queryParameters.put(TARGET_RESOURCE_GROUP, targetResourceGroup);
+ return this;
+ }
+
+ public AlertRequestOptions withTargetResourceType(String targetResourceType) {
+ checkState(!queryParameters.containsKey(TARGET_RESOURCE_TYPE),
+ "Can't have duplicate parameter of targetResourceType");
+ queryParameters.put(TARGET_RESOURCE_TYPE, targetResourceType);
+ return this;
+ }
+
+ public AlertRequestOptions withMonitorService(String monitorService) {
+ checkState(!queryParameters.containsKey(MONITOR_SERVICE), "Can't have duplicate parameter of monitorService");
+ queryParameters.put(MONITOR_SERVICE, monitorService);
+ return this;
+ }
+
+ public AlertRequestOptions withMonitorCondition(String monitorCondition) {
+ checkState(!queryParameters.containsKey(MONITOR_CONDITION),
+ "Can't have duplicate parameter of monitorCondition");
+ queryParameters.put(MONITOR_CONDITION, monitorCondition);
+ return this;
+ }
+
+ public AlertRequestOptions withSeverity(String severity) {
+ checkState(!queryParameters.containsKey(SERVERITY), "Can't have duplicate parameter of severity");
+ queryParameters.put(SERVERITY, severity);
+ return this;
+ }
+
+ public AlertRequestOptions withAlertState(String alertState) {
+ checkState(!queryParameters.containsKey(ALERT_STATE), "Can't have duplicate parameter of alertState");
+ queryParameters.put(ALERT_STATE, alertState);
+ return this;
+ }
+
+ public AlertRequestOptions withAlertRule(String alertRule) {
+ checkState(!queryParameters.containsKey(ALERT_RULE), "Can't have duplicate parameter of alertRule");
+ queryParameters.put(ALERT_RULE, alertRule);
+ return this;
+ }
+
+ public AlertRequestOptions withSmartGroupId(String smartGroupId) {
+ checkState(!queryParameters.containsKey(SMART_GROUP_ID), "Can't have duplicate parameter of smartGroupId");
+ queryParameters.put(SMART_GROUP_ID, smartGroupId);
+ return this;
+ }
+
+ public AlertRequestOptions withIncludeContext(boolean includeContext) {
+ checkState(!queryParameters.containsKey(INCLUDE_CONTEXT), "Can't have duplicate parameter of includeContext");
+ queryParameters.put(INCLUDE_CONTEXT, String.valueOf(includeContext));
+ return this;
+ }
+
+ public AlertRequestOptions withIncludeEgressConfig(boolean includeEgressConfig) {
+ checkState(!queryParameters.containsKey(INCLUDE_EGRESS_CONFIG),
+ "Can't have duplicate parameter of includeEgressConfig");
+ queryParameters.put(INCLUDE_EGRESS_CONFIG, String.valueOf(includeEgressConfig));
+ return this;
+ }
+
+ public AlertRequestOptions withPageCount(int pageCount) {
+ checkState(!queryParameters.containsKey(PAGE_COUNT), "Can't have duplicate parameter of pageCount");
+ queryParameters.put(PAGE_COUNT, String.valueOf(pageCount));
+ return this;
+ }
+
+ public AlertRequestOptions withSortBy(String sortBy) {
+ checkState(!queryParameters.containsKey(SORT_BY), "Can't have duplicate parameter of sortBy");
+ queryParameters.put(SORT_BY, sortBy);
+ return this;
+ }
+
+ public AlertRequestOptions withSortOrder(String sortOrder) {
+ checkState(!queryParameters.containsKey(SORT_ORDER), "Can't have duplicate parameter of sortOrder");
+ queryParameters.put(SORT_ORDER, sortOrder);
+ return this;
+ }
+
+ public AlertRequestOptions withSelect(String select) {
+ checkState(!queryParameters.containsKey(SELECT), "Can't have duplicate parameter of select");
+ queryParameters.put(SELECT, select);
+ return this;
+ }
+
+ public AlertRequestOptions withTimeRange(String timeRange) {
+ checkState(!queryParameters.containsKey(TIME_RANGE), "Can't have duplicate parameter of timeRange");
+ queryParameters.put(TIME_RANGE, timeRange);
+ return this;
+ }
+
+ public AlertRequestOptions withCustomTimeRange(String customTimeRange) {
+ checkState(!queryParameters.containsKey(CUSTOM_TIME_RANGE),
+ "Can't have duplicate parameter of customTimeRange");
+ queryParameters.put(CUSTOM_TIME_RANGE, customTimeRange);
+ return this;
+ }
+
+ public AlertRequestOptions withGroupBy(String groupby) {
+ checkState(!queryParameters.containsKey(GROUP_BY), "Can't have duplicate parameter of groupby");
+ queryParameters.put(GROUP_BY, groupby);
+ return this;
+ }
+
+ public AlertRequestOptions withIncludeSmartGroupsCount(boolean includeSmartGroupsCount) {
+ checkState(!queryParameters.containsKey(INCLUDE_SMART_GROUPS_COUNT),
+ "Can't have duplicate parameter of includeSmartGroupsCount");
+ queryParameters.put(INCLUDE_SMART_GROUPS_COUNT, String.valueOf(includeSmartGroupsCount));
+ return this;
+ }
+
+ /*
+ * This method is intended for testing
+ */
+ @Override
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ AlertRequestOptions options = (AlertRequestOptions) o;
+
+ return buildQueryParameters().equals(options.buildQueryParameters());
+ }
+
+ @Override
+ public int hashCode() {
+ return buildQueryParameters().hashCode();
+ }
+
+ public static class Builder {
+
+ public static AlertRequestOptions targetResource(String targetResource) {
+ return new AlertRequestOptions().withTargetResource(targetResource);
+ }
+
+ public static AlertRequestOptions targetResourceGroup(String targetResourceGroup) {
+ return new AlertRequestOptions().withTargetResourceGroup(targetResourceGroup);
+ }
+
+ public static AlertRequestOptions targetResourceGroupType(String targetResourceGroupType) {
+ return new AlertRequestOptions().withTargetResourceType(targetResourceGroupType);
+ }
+
+ public static AlertRequestOptions monitorService(String monitorService) {
+ return new AlertRequestOptions().withMonitorService(monitorService);
+ }
+
+ public static AlertRequestOptions monitorCondition(String monitorCondition) {
+ return new AlertRequestOptions().withMonitorCondition(monitorCondition);
+ }
+
+ public static AlertRequestOptions severity(String severity) {
+ return new AlertRequestOptions().withSeverity(severity);
+ }
+
+ public static AlertRequestOptions alertState(String alertState) {
+ return new AlertRequestOptions().withAlertState(alertState);
+ }
+
+ public static AlertRequestOptions alertRule(String alertRule) {
+ return new AlertRequestOptions().withAlertRule(alertRule);
+ }
+
+ public static AlertRequestOptions smartGroupId(String smartGroupId) {
+ return new AlertRequestOptions().withSmartGroupId(smartGroupId);
+ }
+
+ public static AlertRequestOptions includeContext(boolean includeContext) {
+ return new AlertRequestOptions().withIncludeContext(includeContext);
+ }
+
+ public static AlertRequestOptions includeEgressConfig(boolean includeEgressConfig) {
+ return new AlertRequestOptions().withIncludeEgressConfig(includeEgressConfig);
+ }
+
+ public static AlertRequestOptions pageCount(int pageCount) {
+ return new AlertRequestOptions().withPageCount(pageCount);
+ }
+
+ public static AlertRequestOptions sortBy(String sortBy) {
+ return new AlertRequestOptions().withSortBy(sortBy);
+ }
+
+ public static AlertRequestOptions sortOrder(String sortOrder) {
+ return new AlertRequestOptions().withSortOrder(sortOrder);
+ }
+
+ public static AlertRequestOptions select(String select) {
+ return new AlertRequestOptions().withSelect(select);
+ }
+
+ public static AlertRequestOptions timeRange(String timeRange) {
+ return new AlertRequestOptions().withTimeRange(timeRange);
+ }
+
+ public static AlertRequestOptions customTimeRange(String customTimeRange) {
+ return new AlertRequestOptions().withCustomTimeRange(customTimeRange);
+ }
+
+ public static AlertRequestOptions groupBy(String groupBy) {
+ return new AlertRequestOptions().withGroupBy(groupBy);
+ }
+
+ public static AlertRequestOptions includeSmartGroupsCount(boolean includeSmartGroupsCount) {
+ return new AlertRequestOptions().withIncludeSmartGroupsCount(includeSmartGroupsCount);
+ }
+
+ }
+
+}
diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/reference/AlertQueryParams.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/reference/AlertQueryParams.java
new file mode 100644
index 0000000000..185a51d1f6
--- /dev/null
+++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/reference/AlertQueryParams.java
@@ -0,0 +1,44 @@
+/*
+ * 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.reference;
+
+public final class AlertQueryParams {
+
+ public static final String TARGET_RESOURCE = "targetResource";
+ public static final String TARGET_RESOURCE_GROUP = "targetResourceGroup";
+ public static final String TARGET_RESOURCE_TYPE = "targetResourceGroupType";
+ public static final String MONITOR_SERVICE = "monitorService";
+ public static final String MONITOR_CONDITION = "monitorCondition";
+ public static final String SERVERITY = "severity";
+ public static final String ALERT_STATE = "alertState";
+ public static final String ALERT_RULE = "alertRule";
+ public static final String SMART_GROUP_ID = "smartGroupId";
+ public static final String INCLUDE_SMART_GROUPS_COUNT = "includeSmartGroupsCount";
+ public static final String INCLUDE_CONTEXT = "includeContext";
+ public static final String INCLUDE_EGRESS_CONFIG = "includeEgressConfig";
+ public static final String PAGE_COUNT = "pageCount";
+ public static final String SORT_BY = "sortBy";
+ public static final String SORT_ORDER = "sortOrder";
+ public static final String SELECT = "select";
+ public static final String TIME_RANGE = "timeRange";
+ public static final String CUSTOM_TIME_RANGE = "customTimeRange";
+ public static final String GROUP_BY = "groupby";
+
+ private AlertQueryParams() {
+ throw new AssertionError("intentionally unimplemented");
+ }
+}
diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ActivityLogAlertApiLiveTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ActivityLogAlertApiLiveTest.java
new file mode 100644
index 0000000000..8a7397b92b
--- /dev/null
+++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ActivityLogAlertApiLiveTest.java
@@ -0,0 +1,113 @@
+/*
+ * 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.features;
+
+import static org.testng.Assert.assertTrue;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.checkerframework.checker.nullness.qual.Nullable;
+import org.jclouds.azurecompute.arm.domain.ActivityLogAlert;
+import org.jclouds.azurecompute.arm.domain.ActivityLogAlertProperties;
+import org.jclouds.azurecompute.arm.domain.AlertRuleAllOfCondition;
+import org.jclouds.azurecompute.arm.domain.AlertRuleAnyOfOrLeafCondition;
+import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+
+@Test(groups = "live", testName = "ActivityLogAlertApiLiveTest", singleThreaded = true)
+public class ActivityLogAlertApiLiveTest extends BaseAzureComputeApiLiveTest {
+
+ private String alertRuleName;
+ private String subscriptionid;
+ private final String GLOBAL = "Global";
+
+ @BeforeClass
+ @Override
+ public void setup() {
+ super.setup();
+ subscriptionid = getSubscriptionId();
+ createTestResourceGroup();
+ alertRuleName = String.format("vn-%s-%s", this.getClass().getSimpleName().toLowerCase(),
+ System.getProperty("user.name"));
+
+ }
+
+ private ActivityLogAlertApi api() {
+ return api.getActivityLogAlertApi(resourceGroupName);
+ }
+
+ @Test
+ public void testCreate() {
+ ActivityLogAlert activityAlert = api().createOrUpdate(alertRuleName, properties(),
+ ImmutableMap.of("createdBy", "jclouds"), GLOBAL);
+ assertTrue(!activityAlert.type().isEmpty());
+ }
+
+ @Test(dependsOnMethods = "testCreate")
+ public void testGet() {
+ final ActivityLogAlert activityLogAlertRule = api().get(alertRuleName);
+ assertTrue(!activityLogAlertRule.name().isEmpty());
+ }
+
+ @Test(dependsOnMethods = "testCreate")
+ public void testList() {
+ List list = api().list();
+ final ActivityLogAlert activityLogAlertRule = api().get(alertRuleName);
+ boolean alertRulePresent = Iterables.any(list, new Predicate() {
+ @Override
+ public boolean apply(@Nullable ActivityLogAlert input) {
+ return input.name().equals(activityLogAlertRule.name());
+ }
+ });
+
+ assertTrue(alertRulePresent);
+ }
+
+ @Test(dependsOnMethods = "testList", alwaysRun = true)
+ public void testDelete() throws Exception {
+ URI uri = api().delete(alertRuleName);
+ assertResourceDeleted(uri);
+ }
+
+ public ActivityLogAlertProperties properties() {
+ return ActivityLogAlertProperties.create("LiveTest", true,
+ Arrays.asList("/subscriptions/" + subscriptionid + "/resourceGroups/" + resourceGroupName), condition(),
+ null);
+
+ }
+
+ public AlertRuleAllOfCondition condition() {
+ final List list1 = new ArrayList<>();
+ final AlertRuleAnyOfOrLeafCondition alertRuleAnyOfOrLeafCondition0 = AlertRuleAnyOfOrLeafCondition.create(null,
+ null, "Administrative", "category");
+ final AlertRuleAnyOfOrLeafCondition alertRuleAnyOfOrLeafCondition1 = AlertRuleAnyOfOrLeafCondition.create(null,
+ null, "Microsoft.Compute/virtualMachines", "resourceType");
+ list1.add(alertRuleAnyOfOrLeafCondition0);
+ list1.add(alertRuleAnyOfOrLeafCondition1);
+ final AlertRuleAllOfCondition condtion = AlertRuleAllOfCondition.create(list1, null);
+ return condtion;
+ }
+
+}
diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ActivityLogAlertApiMockTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ActivityLogAlertApiMockTest.java
new file mode 100644
index 0000000000..1853449a5f
--- /dev/null
+++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ActivityLogAlertApiMockTest.java
@@ -0,0 +1,210 @@
+/*
+ * 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.features;
+
+import static com.google.common.collect.Iterables.isEmpty;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.testng.Assert.assertEquals;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jclouds.azurecompute.arm.domain.ActionGroup;
+import org.jclouds.azurecompute.arm.domain.Actions;
+import org.jclouds.azurecompute.arm.domain.ActivityLogAlert;
+import org.jclouds.azurecompute.arm.domain.ActivityLogAlertProperties;
+import org.jclouds.azurecompute.arm.domain.AlertRuleAllOfCondition;
+import org.jclouds.azurecompute.arm.domain.AlertRuleAnyOfOrLeafCondition;
+import org.jclouds.azurecompute.arm.domain.AlertRuleLeafCondition;
+import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
+import org.testng.annotations.Test;
+
+import okhttp3.mockwebserver.MockResponse;
+
+@Test(groups = "unit", testName = "ActivityLogAlertApiMockTest", singleThreaded = true)
+public class ActivityLogAlertApiMockTest extends BaseAzureComputeApiMockTest {
+
+ public void testList() throws InterruptedException {
+ server.enqueue(jsonResponse("/activitylogalertresourcegroup.json"));
+ final ActivityLogAlertApi activityLogAlertApi = api.getActivityLogAlertApi("myResourceGroup");
+ assertEquals(activityLogAlertApi.list(), getActivityLogRuleList());
+ assertSent(server, "GET",
+ "/subscriptions/SUBSCRIPTIONID/resourcegroups/myResourceGroup/providers/Microsoft.Insights/activityLogAlerts?api-version=2020-10-01");
+ }
+
+ private List getActivityLogRuleList() {
+ List activityLogAlertRules = new ArrayList();
+ activityLogAlertRules.add(ActivityLogAlert.create(
+ "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/microsoft.insights/activityLogAlerts/myActivityLog",
+ "myActivityLog", "Global", "Microsoft.Insights/ActivityLogAlerts", tags(),
+ myActivityLogAlertProperties()));
+ activityLogAlertRules.add(ActivityLogAlert.create(
+ "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/microsoft.insights/activityLogAlerts/simpleActivityLog",
+ "simpleActivityLog", "Global", "Microsoft.Insights/ActivityLogAlerts", null,
+ sampleActivityLogAlertProperties()));
+ return activityLogAlertRules;
+ }
+
+ public ActivityLogAlertProperties myActivityLogAlertProperties() {
+ return ActivityLogAlertProperties.create("", false, scope0(), condition0(), actions());
+ }
+
+ public ActivityLogAlertProperties sampleActivityLogAlertProperties() {
+ return ActivityLogAlertProperties.create("", true, scope1(), condition1(), actions());
+
+ }
+
+ public void testListEmpty() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(404));
+ final ActivityLogAlertApi activityApi = api.getActivityLogAlertApi("groupname");
+ List list = activityApi.list();
+ assertTrue(isEmpty(list));
+ assertSent(server, "GET",
+ "/subscriptions/SUBSCRIPTIONID/resourcegroups/groupname/providers/Microsoft.Insights/activityLogAlerts?api-version=2020-10-01");
+ }
+
+ public void testGet() throws InterruptedException {
+ server.enqueue(jsonResponse("/activitylogalertget.json"));
+ final ActivityLogAlertApi activityApi = api.getActivityLogAlertApi("myResourceGroup");
+ ActivityLogAlert alert = activityApi.get("myActivityLogAlert");
+ assertEquals(alert.location(), "Global");
+ assertSent(server, "GET",
+ "/subscriptions/SUBSCRIPTIONID/resourcegroups/myResourceGroup/providers/Microsoft.Insights/activityLogAlerts/myActivityLogAlert?api-version=2020-10-01");
+ }
+
+ public void testGetReturns404() throws InterruptedException {
+ server.enqueue(response404());
+ final ActivityLogAlertApi activityApi = api.getActivityLogAlertApi("myResourceGroup");
+ ActivityLogAlert alert = activityApi.get("myActivityLogAlert");
+ assertNull(alert);
+ assertSent(server, "GET",
+ "/subscriptions/SUBSCRIPTIONID/resourcegroups/myResourceGroup/providers/Microsoft.Insights/activityLogAlerts/myActivityLogAlert?api-version=2020-10-01");
+ }
+
+ public void testDelete() throws Exception {
+ server.enqueue(response202WithHeader());
+ final ActivityLogAlertApi activityApi = api.getActivityLogAlertApi("myResourceGroup");
+ URI uri = activityApi.delete("myActivityLogAlert");
+ assertEquals(server.getRequestCount(), 1);
+ assertNotNull(uri);
+ assertSent(server, "DELETE",
+ "/subscriptions/SUBSCRIPTIONID/resourcegroups/myResourceGroup/providers/Microsoft.Insights/activityLogAlerts/myActivityLogAlert?api-version=2020-10-01");
+ }
+
+ public void testDeleteReturns404() throws Exception {
+ server.enqueue(response404());
+ final ActivityLogAlertApi activityApi = api.getActivityLogAlertApi("myResourceGroup");
+ URI uri = activityApi.delete("myActivityLogAlert");
+ assertEquals(server.getRequestCount(), 1);
+ assertNull(uri);
+ assertSent(server, "DELETE",
+ "/subscriptions/SUBSCRIPTIONID/resourcegroups/myResourceGroup/providers/Microsoft.Insights/activityLogAlerts/myActivityLogAlert?api-version=2020-10-01");
+ }
+
+ public Map tags() {
+ Map tags = new HashMap<>();
+ tags.put("key1", "value1");
+ tags.put("key2", "value2");
+ return tags;
+ }
+
+ public List scope0() {
+ List list = new ArrayList();
+ list.add(
+ "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM");
+ return list;
+ }
+
+ public List scope1() {
+ List list = new ArrayList();
+ list.add(
+ "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/simpleVM");
+
+ return list;
+ }
+
+ public AlertRuleAllOfCondition condition0() {
+ final List list1 = new ArrayList<>();
+ final AlertRuleAnyOfOrLeafCondition alertRuleAnyOfOrLeafCondition = AlertRuleAnyOfOrLeafCondition.create(null,
+ null, "ServiceHealth", "category");
+ list1.add(alertRuleAnyOfOrLeafCondition);
+ final AlertRuleAllOfCondition condtion = AlertRuleAllOfCondition.create(list1, "");
+ return condtion;
+ }
+
+ public AlertRuleAllOfCondition condition1() {
+ final List list1 = new ArrayList<>();
+ final AlertRuleAnyOfOrLeafCondition alertRuleAnyOfOrLeafCondition0 = AlertRuleAnyOfOrLeafCondition.create(null,
+ null, "Administrative", "category");
+ final AlertRuleAnyOfOrLeafCondition alertRuleAnyOfOrLeafCondition1 = AlertRuleAnyOfOrLeafCondition.create(null,
+ null, "Microsoft.Compute/virtualMachines/write", "operationName");
+ list1.add(alertRuleAnyOfOrLeafCondition0);
+ list1.add(alertRuleAnyOfOrLeafCondition1);
+ final AlertRuleAllOfCondition condtion = AlertRuleAllOfCondition.create(list1, null);
+ return condtion;
+ }
+
+ public List allOf() {
+ List list = new ArrayList<>();
+ list.add(anyOfOrLeafCondition());
+ return list;
+ }
+
+ public AlertRuleAnyOfOrLeafCondition anyOfOrLeafCondition() {
+ AlertRuleAnyOfOrLeafCondition alertRule = AlertRuleAnyOfOrLeafCondition.create(leafCondition(), null, null,
+ null);
+ return alertRule;
+ }
+
+ public List leafCondition() {
+ final List list = new ArrayList<>();
+ final AlertRuleLeafCondition alertRuleLeafCondition = AlertRuleLeafCondition.create(null, "ServiceHealth",
+ "category");
+ list.add(alertRuleLeafCondition);
+ return list;
+ }
+
+ public Actions actions() {
+ List list = new ArrayList<>();
+ ActionGroup actionGroup = ActionGroup.create(
+ "/subscriptions/SUBSCRIPTIONID/resourcegroups/myResourceGroup/providers/microsoft.insights/actiongroups/myAction",
+ null);
+ list.add(actionGroup);
+ Actions action = Actions.create(list);
+ return action;
+ }
+
+ public void testCreate() throws Exception {
+ server.enqueue(jsonResponse("/activitylogalertcreate.json"));
+ final ActivityLogAlertApi activityApi = api.getActivityLogAlertApi("myResourceGroup");
+ ActivityLogAlert activityAlert = activityApi.createOrUpdate("myActivityLogAlertRule",
+ myActivityLogAlertProperties(), new HashMap<>(), "Global");
+ final ActivityLogAlert expected = ActivityLogAlert.create(
+ "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/microsoft.insights/activityLogAlerts/myActivityLogAlertRule",
+ "myActivityLogAlertRule", "Global", "Microsoft.Insights/ActivityLogAlerts", tags(),
+ myActivityLogAlertProperties());
+ assertEquals(activityAlert.id(), expected.id());
+ assertSent(server, "PUT",
+ "/subscriptions/SUBSCRIPTIONID/resourcegroups/myResourceGroup/providers/Microsoft.Insights/activityLogAlerts/myActivityLogAlertRule?validating=false&api-version=2020-10-01");
+
+ }
+}
diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/AlertApiLiveTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/AlertApiLiveTest.java
new file mode 100644
index 0000000000..66bba8c22c
--- /dev/null
+++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/AlertApiLiveTest.java
@@ -0,0 +1,77 @@
+/*
+ * 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.features;
+
+import static org.junit.Assert.assertEquals;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.List;
+
+import org.jclouds.azurecompute.arm.domain.Alert;
+import org.jclouds.azurecompute.arm.domain.AlertModification;
+import org.jclouds.azurecompute.arm.domain.AlertSummary;
+import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest;
+import org.jclouds.azurecompute.arm.options.AlertRequestOptions;
+import org.testng.annotations.Test;
+
+@Test(groups = "live", testName = "AlertApiLiveTest", singleThreaded = true)
+public class AlertApiLiveTest extends BaseAzureComputeApiLiveTest {
+
+ private String alertId;
+
+ private AlertApi alertApi() {
+ return api.getAlertApi("");
+ }
+
+ @Test
+ public void testList() {
+ AlertRequestOptions pageCount = AlertRequestOptions.Builder.pageCount(1);
+ List result = alertApi().list(pageCount);
+ System.out.println(result.size());
+ assertNotNull(result);
+ assertTrue(result.size() > 0);
+ final String id = result.get(0).id();
+ alertId = id.substring(id.lastIndexOf("/") + 1);
+ }
+
+ @Test(dependsOnMethods = "testList")
+ public void testGetById() {
+ Alert alert = alertApi().get(alertId);
+ assertNotNull(alert);
+ }
+
+ @Test(dependsOnMethods = "testList")
+ public void testGetHistory() {
+ AlertModification history = alertApi().getHistory(alertId);
+ assertNotNull(history);
+ }
+
+ @Test(dependsOnMethods = "testList")
+ public void testGetSummary() {
+ AlertRequestOptions groupByOption = AlertRequestOptions.Builder.groupBy("severity");
+ AlertSummary summary = alertApi().getSummary(groupByOption);
+ assertNotNull(summary);
+ }
+
+ @Test(dependsOnMethods = "testList")
+ public void testAlertChangeState() {
+ Alert alert = alertApi().changeState(alertId, "Closed");
+ assertNotNull(alert);
+ assertEquals("Closed", alertApi().get(alertId).properties().essentials().alertState().name());
+ }
+}
diff --git a/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/AlertApiMockTest.java b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/AlertApiMockTest.java
new file mode 100644
index 0000000000..c692d9d6de
--- /dev/null
+++ b/providers/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/AlertApiMockTest.java
@@ -0,0 +1,134 @@
+/*
+ * 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.features;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.testng.Assert.assertEquals;
+
+import java.util.List;
+
+import org.jclouds.azurecompute.arm.domain.Alert;
+import org.jclouds.azurecompute.arm.domain.AlertModification;
+import org.jclouds.azurecompute.arm.domain.AlertSummary;
+import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
+import org.jclouds.azurecompute.arm.options.AlertRequestOptions;
+import org.testng.annotations.Test;
+
+import static com.google.common.collect.Iterables.isEmpty;
+import okhttp3.mockwebserver.MockResponse;
+
+@Test(groups = "unit", testName = "AlertApiMockTest", singleThreaded = true)
+public class AlertApiMockTest extends BaseAzureComputeApiMockTest {
+
+ public void testGetById() throws InterruptedException {
+ server.enqueue(jsonResponse("/alertsgetbyid.json"));
+ final AlertApi alertApi = api.getAlertApi("resourceGroups/myResourceGroup");
+ Alert alert = alertApi.get("60c4d62b-xxxx-46d8-0000-b6dd8c4a769e");
+ final String alertName = alert.name();
+ assertEquals(alertName, "SampleAlert");
+ assertSent(server, "GET",
+ "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.AlertsManagement/alerts/60c4d62b-xxxx-46d8-0000-b6dd8c4a769e?api-version=2019-03-01");
+ }
+
+ public void testGetByIdEmpty() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(404));
+ final AlertApi alertApi = api.getAlertApi("resourceGroups/myResourceGroup");
+ Alert alert = alertApi.get("60c4d62b-xxxx-46d8-0000-b6dd8c4a769e");
+ assertNull(alert);
+ assertSent(server, "GET",
+ "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.AlertsManagement/alerts/60c4d62b-xxxx-46d8-0000-b6dd8c4a769e?api-version=2019-03-01");
+ }
+
+ public void testGetHistory() throws InterruptedException {
+ server.enqueue(jsonResponse("/alertgethistory.json"));
+ final AlertApi alertApi = api.getAlertApi("resourceGroups/myResourceGroup");
+ AlertModification history = alertApi.getHistory("d9db1f27-ce08-4c6d-8ab6-c0a8fbd8bf64");
+ final String type = history.type();
+ assertEquals(type, "Microsoft.AlertsManagement/alerts");
+ assertSent(server, "GET",
+ "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.AlertsManagement/alerts/d9db1f27-ce08-4c6d-8ab6-c0a8fbd8bf64/history?api-version=2019-03-01");
+ }
+
+ public void testGetHistoryEmpty() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(404));
+ final AlertApi alertApi = api.getAlertApi("resourceGroups/myResourceGroup");
+ AlertModification history = alertApi.getHistory("d9db1f27-ce08-4c6d-8ab6-c0a8fbd8bf64");
+ assertNull(history);
+ assertSent(server, "GET",
+ "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.AlertsManagement/alerts/d9db1f27-ce08-4c6d-8ab6-c0a8fbd8bf64/history?api-version=2019-03-01");
+ }
+
+ public void testGetSummary() throws InterruptedException {
+ server.enqueue(jsonResponse("/alertgetsummary.json"));
+ final AlertApi alertApi = api.getAlertApi("resourceGroups/myResourceGroup");
+ AlertRequestOptions groupByOption = AlertRequestOptions.Builder.groupBy("severity");
+ AlertSummary summary = alertApi.getSummary(groupByOption);
+ final String alertName = summary.name();
+ assertEquals(alertName, "current");
+ assertSent(server, "GET",
+ "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.AlertsManagement/alertsSummary?groupby=severity&api-version=2019-03-01");
+ }
+
+ public void testGetSummaryEmpty() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(404));
+ final AlertApi alertApi = api.getAlertApi("resourceGroups/myResourceGroup");
+ AlertRequestOptions groupByOption = AlertRequestOptions.Builder.groupBy("severity");
+ AlertSummary summary = alertApi.getSummary(groupByOption);
+ assertNull(summary);
+ assertSent(server, "GET",
+ "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.AlertsManagement/alertsSummary?groupby=severity&api-version=2019-03-01");
+ }
+
+ public void testGetAll() throws InterruptedException {
+ server.enqueue(jsonResponse("/alertgetall.json"));
+ final AlertApi alertApi = api.getAlertApi("resourceGroups/myResourceGroup");
+ List list = alertApi.list();
+ assertEquals(list.get(0).name(), "HostPoolAlert");
+ assertSent(server, "GET",
+ "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.AlertsManagement/alerts?api-version=2019-03-01");
+ }
+
+ public void testGetAllEmpty() throws Exception {
+ server.enqueue(new MockResponse().setResponseCode(404));
+ final AlertApi alertApi = api.getAlertApi("resourceGroups/myResourceGroup");
+ List list = alertApi.list();
+ assertTrue(isEmpty(list));
+ assertSent(server, "GET",
+ "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.AlertsManagement/alerts?api-version=2019-03-01");
+ }
+
+ public void testAlertChangeState() throws InterruptedException {
+ server.enqueue(jsonResponse("/alertchangestate.json"));
+ final AlertApi alertApi = api.getAlertApi("resourceGroups/myResourceGroup");
+ Alert alert = alertApi.changeState("650d5726-xxxx-4e8c-0000-504d577da210", "Closed");
+ assertNotNull(alert);
+ assertSent(server, "POST",
+ "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.AlertsManagement/alerts/650d5726-xxxx-4e8c-0000-504d577da210/changestate?newState=Closed&api-version=2019-03-01");
+ }
+
+ public void testAlertChangeStateReturns404() throws InterruptedException {
+ server.enqueue(response404());
+ final AlertApi alertApi = api.getAlertApi("resourceGroups/myResourceGroup");
+ Alert alert = alertApi.changeState("650d5726-xxxx-4e8c-0000-504d577da210", "Closed");
+ assertNull(alert);
+ assertSent(server, "POST",
+ "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.AlertsManagement/alerts/650d5726-xxxx-4e8c-0000-504d577da210/changestate?newState=Closed&api-version=2019-03-01");
+
+ }
+}
diff --git a/providers/azurecompute-arm/src/test/resources/activitylogalertcreate.json b/providers/azurecompute-arm/src/test/resources/activitylogalertcreate.json
new file mode 100644
index 0000000000..ab38fa54a9
--- /dev/null
+++ b/providers/azurecompute-arm/src/test/resources/activitylogalertcreate.json
@@ -0,0 +1,33 @@
+{
+ "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/microsoft.insights/activityLogAlerts/myActivityLogAlertRule",
+ "type": "Microsoft.Insights/ActivityLogAlerts",
+ "name": "myActivityLogAlertRule",
+ "location": "Global",
+ "properties": {
+ "scopes": [
+ "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/VM"
+ ],
+ "condition": {
+ "allOf": [
+ {
+ "field": "category",
+ "equals": "ServiceHealth",
+ "containsAny": null,
+ "odata.type": null
+ }
+ ],
+ "odata.type": ""
+ },
+ "actions": {
+ "actionGroups": [
+ {
+ "actionGroupId": "/subscriptions/SUBSCRIPTIONID/resourcegroups/myResourceGroup/providers/microsoft.insights/actiongroups/myAction",
+ "webhookProperties": null
+ }
+ ]
+ },
+ "enabled": false,
+ "description": ""
+ },
+ "identity": null
+}
\ No newline at end of file
diff --git a/providers/azurecompute-arm/src/test/resources/activitylogalertget.json b/providers/azurecompute-arm/src/test/resources/activitylogalertget.json
new file mode 100644
index 0000000000..8990041c3c
--- /dev/null
+++ b/providers/azurecompute-arm/src/test/resources/activitylogalertget.json
@@ -0,0 +1,46 @@
+{
+ "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/microsoft.insights/activityLogAlerts/myActivityLogAlert",
+ "type": "Microsoft.Insights/ActivityLogAlerts",
+ "name": "myActivityLogAlert",
+ "location": "Global",
+ "kind": null,
+ "tags": {
+ "key1": "Test",
+ "key2": "Testing"
+ },
+ "properties": {
+ "scopes": [
+ "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/VM"
+ ],
+ "condition": {
+ "allOf": [
+ {
+ "field": "category",
+ "equals": "Administrative",
+ "containsAny": null,
+ "odata.type": null
+ },
+ {
+ "field": "operationName",
+ "equals": "Microsoft.Compute/virtualMachines/write",
+ "containsAny": null,
+ "odata.type": null
+ }
+ ],
+ "odata.type": null
+ },
+ "actions": {
+ "actionGroups": [
+ {
+ "actionGroupId": "/subscriptions/SUBSCRIPTIONID/resourcegroups/armdemo/providers/microsoft.insights/actiongroups/actions",
+ "webhookProperties": {
+
+ }
+ }
+ ]
+ },
+ "enabled": true,
+ "description": "test"
+ },
+ "identity": null
+}
\ No newline at end of file
diff --git a/providers/azurecompute-arm/src/test/resources/activitylogalertresourcegroup.json b/providers/azurecompute-arm/src/test/resources/activitylogalertresourcegroup.json
new file mode 100644
index 0000000000..053e909e93
--- /dev/null
+++ b/providers/azurecompute-arm/src/test/resources/activitylogalertresourcegroup.json
@@ -0,0 +1,79 @@
+{
+ "value": [
+ {
+ "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/microsoft.insights/activityLogAlerts/myActivityLog",
+ "type": "Microsoft.Insights/ActivityLogAlerts",
+ "name": "myActivityLog",
+ "location": "Global",
+ "kind": null,
+ "tags": {
+ "key1": "value1",
+ "key2": "value2"
+ },
+ "properties": {
+ "scopes": [
+ "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM"
+ ],
+ "condition": {
+ "allOf": [
+ {
+ "field": "category",
+ "equals": "ServiceHealth",
+ "containsAny": null
+ }
+ ],
+ "odata.type": ""
+ },
+ "actions": {
+ "actionGroups": [
+ {
+ "actionGroupId": "/subscriptions/SUBSCRIPTIONID/resourcegroups/myResourceGroup/providers/microsoft.insights/actiongroups/myAction",
+ "webhookProperties": null
+ }
+ ]
+ },
+ "enabled": false,
+ "description": ""
+ },
+ "identity": null
+ },
+ {
+ "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/microsoft.insights/activityLogAlerts/simpleActivityLog",
+ "type": "Microsoft.Insights/ActivityLogAlerts",
+ "name": "simpleActivityLog",
+ "location": "Global",
+ "kind": null,
+ "properties": {
+ "scopes": [
+ "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/simpleVM"
+ ],
+ "condition": {
+ "allOf": [
+ {
+ "field": "category",
+ "equals": "Administrative",
+ "containsAny": null
+ },
+ {
+ "field": "operationName",
+ "equals": "Microsoft.Compute/virtualMachines/write",
+ "containsAny": null
+ }
+ ],
+ "odata.type": null
+ },
+ "actions": {
+ "actionGroups": [
+ {
+ "actionGroupId": "/subscriptions/SUBSCRIPTIONID/resourcegroups/myResourceGroup/providers/microsoft.insights/actiongroups/myAction",
+ "webhookProperties": null
+ }
+ ]
+ },
+ "enabled": true,
+ "description": ""
+ },
+ "identity": null
+ }
+ ]
+}
\ No newline at end of file
diff --git a/providers/azurecompute-arm/src/test/resources/alertchangestate.json b/providers/azurecompute-arm/src/test/resources/alertchangestate.json
new file mode 100644
index 0000000000..de5fac4f65
--- /dev/null
+++ b/providers/azurecompute-arm/src/test/resources/alertchangestate.json
@@ -0,0 +1,28 @@
+{
+ "properties": {
+ "essentials": {
+ "severity": "Sev4",
+ "signalType": "Log",
+ "alertState": "Closed",
+ "monitorCondition": "Fired",
+ "monitorService": "ActivityLog Administrative",
+ "targetResource": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/microsoft.desktopvirtualization/hostpools/test",
+ "targetResourceName": "test",
+ "targetResourceGroup": "simple-vm",
+ "targetResourceType": "microsoft.desktopvirtualization/hostpools",
+ "sourceCreatedId": "e9bac899-9b62-4a4c-bdf0-03d0b36de44d_b19412575e566c1d66904f19b7bd652c",
+ "smartGroupId": "5578c276-b1ac-449c-99e2-7890fa1ff59b",
+ "alertRule": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/microsoft.insights/activityLogAlerts/HostPoolAlert",
+ "startDateTime": "2021-12-16T11:18:24.7655495Z",
+ "lastModifiedDateTime": "2021-12-17T05:57:33.8879323Z",
+ "lastModifiedUserName": "abc@xyz.com",
+ "actionStatus": {
+ "isSuppressed": false
+ },
+ "description": ""
+ }
+ },
+ "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/microsoft.desktopvirtualization/hostpools/test/providers/Microsoft.AlertsManagement/alerts/650d5726-xxxx-4e8c-0000-504d577da210",
+ "type": "Microsoft.AlertsManagement/alerts",
+ "name": "HostPoolAlert"
+}
\ No newline at end of file
diff --git a/providers/azurecompute-arm/src/test/resources/alertgetall.json b/providers/azurecompute-arm/src/test/resources/alertgetall.json
new file mode 100644
index 0000000000..ea9001d45f
--- /dev/null
+++ b/providers/azurecompute-arm/src/test/resources/alertgetall.json
@@ -0,0 +1,32 @@
+{
+ "value": [
+ {
+ "properties": {
+ "essentials": {
+ "alertRule": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/microsoft.insights/activityLogAlerts/HostPoolAlert",
+ "alertState": "New",
+ "severity": "Sev4",
+ "signalType": "Log",
+ "monitorCondition": "Fired",
+ "monitorService": "ActivityLog Administrative",
+ "targetResource": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/microsoft.desktopvirtualization/hostpools/test",
+ "targetResourceName": "test",
+ "targetResourceGroup": "tidal-vm",
+ "targetResourceType": "microsoft.desktopvirtualization/hostpools",
+ "sourceCreatedId": "e9bac899-9b62-4a4c-bdf0-03d0b36de44d_b19412575e566c1d66904f19b7bd652c",
+ "smartGroupId": "5578c276-b1ac-449c-99e2-7890fa1ff59b",
+ "startDateTime": "2021-12-16T11:18:24.7655495Z",
+ "lastModifiedDateTime": "2021-12-16T11:18:24.7655495Z",
+ "lastModifiedUserName": "System",
+ "actionStatus": {
+ "isSuppressed": false
+ },
+ "description": ""
+ }
+ },
+ "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/microsoft.desktopvirtualization/hostpools/test/providers/Microsoft.AlertsManagement/alerts/650d5726-44d5-4e8c-a7b4-504d577da210",
+ "type": "Microsoft.AlertsManagement/alerts",
+ "name": "HostPoolAlert"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/providers/azurecompute-arm/src/test/resources/alertgethistory.json b/providers/azurecompute-arm/src/test/resources/alertgethistory.json
new file mode 100644
index 0000000000..8f6eafda5b
--- /dev/null
+++ b/providers/azurecompute-arm/src/test/resources/alertgethistory.json
@@ -0,0 +1,19 @@
+{
+ "properties": {
+ "alertId": "d9db1f27-ce08-4c6d-8ab6-c0a8fbd8bf64",
+ "modifications": [
+ {
+ "modificationEvent": "AlertCreated",
+ "oldValue": "",
+ "newValue": "",
+ "modifiedAt": "2021-12-15T18:01:42.4020003Z",
+ "modifiedBy": "System",
+ "comments": "",
+ "description": "Alert fired"
+ }
+ ]
+ },
+ "id": "/subscriptions/SUBSCRIPTIONID/resourcegroups/myResourceGroup/providers/microsoft.compute/virtualmachines/mac/providers/Microsoft.AlertsManagement/alerts/d9db1f27-ce08-4c6d-8ab6-c0a8fbd8bf64/history/default",
+ "type": "Microsoft.AlertsManagement/alerts",
+ "name": "myRule"
+}
\ No newline at end of file
diff --git a/providers/azurecompute-arm/src/test/resources/alertgetsummary.json b/providers/azurecompute-arm/src/test/resources/alertgetsummary.json
new file mode 100644
index 0000000000..b3329a0875
--- /dev/null
+++ b/providers/azurecompute-arm/src/test/resources/alertgetsummary.json
@@ -0,0 +1,31 @@
+{
+ "properties": {
+ "groupedby": "severity",
+ "total": 1,
+ "values": [
+ {
+ "name": "Sev0",
+ "count": 0
+ },
+ {
+ "name": "Sev1",
+ "count": 0
+ },
+ {
+ "name": "Sev2",
+ "count": 0
+ },
+ {
+ "name": "Sev3",
+ "count": 0
+ },
+ {
+ "name": "Sev4",
+ "count": 1
+ }
+ ]
+ },
+ "id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/microsoft.desktopvirtualization/hostpools/test/providers/Microsoft.AlertsManagement/alertsSummary/current",
+ "type": "Microsoft.AlertsManagement/alertsSummary",
+ "name": "current"
+}
\ No newline at end of file
diff --git a/providers/azurecompute-arm/src/test/resources/alertsgetbyid.json b/providers/azurecompute-arm/src/test/resources/alertsgetbyid.json
new file mode 100644
index 0000000000..096152d359
--- /dev/null
+++ b/providers/azurecompute-arm/src/test/resources/alertsgetbyid.json
@@ -0,0 +1,29 @@
+{
+ "properties": {
+ "essentials": {
+ "severity": "Sev4",
+ "signalType": "Log",
+ "alertState": "Acknowledged",
+ "monitorCondition": "Fired",
+ "monitorService": "ActivityLog Administrative",
+ "targetResource": "/subscriptions/SUBSCRIPTIONID/resourcegroups/myResourceGroup/providers/microsoft.compute/virtualmachines/mac",
+ "targetResourceName": "mac",
+ "targetResourceGroup": "myResourceGroup",
+ "targetResourceType": "microsoft.compute/virtualmachines",
+ "sourceCreatedId": "4f4f8514-8dcc-483d-bfd4-90142a63fe06_952656992461616e11c062eeaaed472d",
+ "smartGroupId": "54ebf82c-b522-4520-b582-6c6382477b6a",
+ "smartGroupingReason": "Similar to other alerts in the group",
+ "alertRule": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleAlert",
+ "startDateTime": "2021-12-15T04:21:17.7200826Z",
+ "lastModifiedDateTime": "2021-12-15T04:23:20.9184138Z",
+ "lastModifiedUserName": "abc@xyz.com",
+ "actionStatus": {
+ "isSuppressed": false
+ },
+ "description": ""
+ }
+ },
+ "id": "/subscriptions/SUBSCRIPTIONID/resourcegroups/myResourceGroup/providers/microsoft.compute/virtualmachines/mac/providers/Microsoft.AlertsManagement/alerts/60c4d62b-xxxx-46d8-0000-b6dd8c4a769e",
+ "type": "Microsoft.AlertsManagement/alerts",
+ "name": "SampleAlert"
+}
\ No newline at end of file