This is an automated email from the ASF dual-hosted git repository. gaul pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/jclouds.git
commit 2b16b55e333309259b57f74792fd0d5cc9d0b912 Author: SATYANAN-ANAND <[email protected]> AuthorDate: Tue Feb 1 03:29:47 2022 -0800 JCLOUDS-1596: Support Activity Log Alert Operations --- .../jclouds/azurecompute/arm/AzureComputeApi.java | 520 +++++++++++---------- .../arm/AzureComputeProviderMetadata.java | 2 + .../azurecompute/arm/domain/ActionGroup.java | 52 +++ .../jclouds/azurecompute/arm/domain/Actions.java | 38 ++ .../azurecompute/arm/domain/ActivityLogAlert.java | 92 ++++ .../arm/domain/ActivityLogAlertProperties.java | 72 +++ .../arm/domain/AlertRuleAllOfCondition.java | 57 +++ .../arm/domain/AlertRuleAnyOfOrLeafCondition.java | 67 +++ .../arm/domain/AlertRuleLeafCondition.java | 63 +++ .../arm/features/ActivityLogAlertApi.java | 87 ++++ 10 files changed, 814 insertions(+), 236 deletions(-) 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 08a6769..9d2b159 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 @@ -20,6 +20,7 @@ import java.io.Closeable; 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.AvailabilitySetApi; import org.jclouds.azurecompute.arm.features.DeploymentApi; import org.jclouds.azurecompute.arm.features.DiskApi; @@ -54,244 +55,291 @@ import com.google.common.base.Supplier; import com.google.inject.Provides; /** - * The Azure Resource Manager API is a REST API for managing your services and deployments. + * The Azure Resource Manager API is a REST API for managing your services and + * deployments. * <p> * - * @see <a href="https://msdn.microsoft.com/en-us/library/azure/dn790568.aspx" >doc</a> + * @see <a href="https://msdn.microsoft.com/en-us/library/azure/dn790568.aspx" + * >doc</a> */ public interface AzureComputeApi extends Closeable { - - /** - * The Azure Resource Manager API includes operations for managing resource groups in your subscription. - * - * @see <a href="https://msdn.microsoft.com/en-us/library/azure/dn790546.aspx">docs</a> - */ - @Delegate - ResourceGroupApi getResourceGroupApi(); - - /** - * Provides access to the Job tracking API. - */ - @Delegate - JobApi getJobApi(); - - /** - * This Azure Resource Manager API provides all of the locations that are available for resource providers - * - * @see <a href="https://msdn.microsoft.com/en-US/library/azure/dn790540.aspx">docs</a> - */ - @Delegate - LocationApi getLocationApi(); - - /** - * The Azure Resource Manager API includes operations for managing the storage accounts in your subscription. - * - * @see <https://msdn.microsoft.com/en-us/library/mt163683.aspx">docs</a> - */ - @Delegate - StorageAccountApi getStorageAccountApi(@PathParam("resourceGroup") String resourceGroup); - - /** - * The Subnet API includes operations for managing the subnets in your virtual network. - * - * @see <a href="https://msdn.microsoft.com/en-us/library/azure/mt163621.aspx">docs</a> - */ - @Delegate - SubnetApi getSubnetApi(@PathParam("resourcegroup") String resourcegroup, - @PathParam("virtualnetwork") String virtualnetwork); - - /** - * The Virtual Network API includes operations for managing the virtual networks in your subscription. - * - * @see <a href="https://msdn.microsoft.com/en-us/library/azure/mt163661.aspx">docs</a> - */ - @Delegate - VirtualNetworkApi getVirtualNetworkApi(@Nullable @PathParam("resourcegroup") String resourcegroup); - - - /** - * The Network Interface Card API includes operations for managing the NICs in your subscription. - * - * @see <a href="https://msdn.microsoft.com/en-us/library/mt163668.aspx">docs</a> - */ - @Delegate - NetworkInterfaceCardApi getNetworkInterfaceCardApi(@Nullable @PathParam("resourcegroup") String resourcegroup); - - /** - * The Public IP Address API includes operations for managing public ID Addresses for NICs in your subscription. - * - * @see <a href="https://msdn.microsoft.com/en-us/library/azure/mt163638.aspx">docs</a> - */ - @Delegate - PublicIPAddressApi getPublicIPAddressApi(@Nullable @PathParam("resourcegroup") String resourcegroup); - - - /** - * The Virtual Machine API includes operations for managing the virtual machines in your subscription. - * - * @see <a href="https://msdn.microsoft.com/en-us/library/azure/mt163630.aspx">docs</a> - */ - @Delegate - VirtualMachineApi getVirtualMachineApi(@Nullable @PathParam("resourceGroup") String resourceGroup); - - /** - * The Virtual Machine Scale Set API includes operations for managing the virtual machines in your subscription. - * - * @see <a href="https://msdn.microsoft.com/en-us/library/azure/mt163630.aspx">docs</a> - */ - @Delegate - VirtualMachineScaleSetApi getVirtualMachineScaleSetApi(@PathParam("resourceGroup") String resourceGroup); - - /** - * This Azure Resource Manager API lists all available virtual machine sizes for a subscription in a given region - * - * @see <a href="https://msdn.microsoft.com/en-us/library/azure/mt269440.aspx">docs</a> - */ - @Delegate - VMSizeApi getVMSizeApi(@PathParam("location") String location); - - /** - * The Azure Resource Manager API gets all the OS images in your subscription. - * - * @see <a href="https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages">docs</a> - */ - @Delegate - OSImageApi getOSImageApi(@PathParam("location") String location); - - /** - * The Deployment API allows for the management of Azure Resource Manager resources through the use of templates. - * - * @see <a href="https://msdn.microsoft.com/en-us/library/azure/dn790549.aspx">docs</a> - */ - @Delegate - DeploymentApi getDeploymentApi(@PathParam("resourcegroup") String resourceGroup); - - /** - * The NetworkSecurityGroup API includes operations for managing network security groups within your subscription. - * - * @see <a href="https://msdn.microsoft.com/en-us/library/azure/mt163615.aspx">docs</a> - */ - @Delegate - NetworkSecurityGroupApi getNetworkSecurityGroupApi(@Nullable @PathParam("resourcegroup") String resourcegroup); - - /** - * The NetworkSecurityRule API includes operations for managing network security rules within a network security group. - * - * @see <a href="https://msdn.microsoft.com/en-us/library/azure/mt163580.aspx">docs</a> - */ - @Delegate - NetworkSecurityRuleApi getNetworkSecurityRuleApi(@PathParam("resourcegroup") String resourcegroup, - @PathParam("networksecuritygroup") String networksecuritygroup); - - /** - * The LoadBalancer API includes operations for managing load balancers - * within your subscription. - * - * @see <a href= - * "https://msdn.microsoft.com/en-us/library/azure/mt163574.aspx">docs - * </a> - */ - @Delegate - LoadBalancerApi getLoadBalancerApi(@Nullable @PathParam("resourcegroup") String resourcegroup); - - /** - * The AvailabilitySet API includes operations for managing availability sets - * within your subscription. - * - * @see <a href= - * "https://docs.microsoft.com/en-us/rest/api/compute/availabilitysets">docs - * </a> - */ - @Delegate - AvailabilitySetApi getAvailabilitySetApi(@PathParam("resourcegroup") String resourcegroup); - - /** - * The Azure Resource Provider API provides information about a resource provider and its supported resource types. - * - * @see <a href="https://msdn.microsoft.com/en-us/library/azure/dn790534.aspx">docs</a> - */ - @Delegate - ResourceProviderApi getResourceProviderApi(); - - /** - * The ManagedDataDisk API includes operations for managing data disks within your subscription. - * - * @see <a href="https://docs.microsoft.com/en-us/rest/api/manageddisks/disks/disks-rest-api">docs</a> - */ - @Delegate - DiskApi getDiskApi(@PathParam("resourcegroup") String resourcegroup); - - /** - * The virtual machine image API includes operations for managing data disks within your subscription. - * - * @see <a href="https://docs.microsoft.com/en-us/rest/api/manageddisks/images/images-rest-api">docs</a> - */ - @Delegate - ImageApi getVirtualMachineImageApi(@PathParam("resourcegroup") String resourcegroup); - - /** - * The metrics API includes operations to get insights into entities within your - * subscription. - * - * @see <a href="https://docs.microsoft.com/en-us/rest/api/monitor/metrics">docs</a> - */ - @Delegate - MetricsApi getMetricsApi(@PathParam("resourceid") String resourceid); - - /** - * The metric definitions API includes operations to get insights available for entities within your - * subscription. - * - * @see <a href="https://docs.microsoft.com/en-us/rest/api/monitor/metricdefinitions">docs</a> - */ - @Delegate - MetricDefinitionsApi getMetricsDefinitionsApi(@PathParam("resourceid") String resourceid); - - /** - * The Azure Active Directory Graph API provides programmatic access to Azure - * AD through REST API endpoints. - * - * @see <a href="https://docs.microsoft.com/en-us/rest/api/graphrbac/">docs</a> - */ - @Delegate - GraphRBACApi getGraphRBACApi(); - - /** - * Managing your key vaults as well as the keys, secrets, and certificates within your key vaults can be - * accomplished through a REST interface. - * - * @see <a href="https://docs.microsoft.com/en-us/rest/api/keyvault/">docs</a> - */ - @Delegate - VaultApi getVaultApi(@PathParam("resourcegroup") String resourcegroup); - - /** - * Management features for Local Network Gateways. - * - * @see <a href="https://docs.microsoft.com/en-us/rest/api/network-gateway/localnetworkgateways">docs</a> - */ - @Delegate - LocalNetworkGatewayApi getLocalNetworkGatewayApi(@PathParam("resourcegroup") String resourcegroup); - - /** - * Management features for Virtual Network Gateways. - * - * @see <a href="https://docs.microsoft.com/en-us/rest/api/network-gateway/virtualnetworkgateways">docs</a> - */ - @Delegate - VirtualNetworkGatewayApi getVirtualNetworkGatewayApi(@PathParam("resourcegroup") String resourcegroup); - - /** - * Management features for Virtual Network Gateway Connections. - * - * @see <a href="https://docs.microsoft.com/en-us/rest/api/network-gateway/virtualnetworkgatewayconnections">docs</a> - */ - @Delegate - VirtualNetworkGatewayConnectionApi getVirtualNetworkGatewayConnectionApi(@PathParam("resourcegroup") String resourcegroup); - - /** - * Returns the information about the current service principal. - */ - @Provides - Supplier<ServicePrincipal> getServicePrincipal(); + + /** + * The Azure Resource Manager API includes operations for managing resource + * groups in your subscription. + * + * @see <a href= + * "https://msdn.microsoft.com/en-us/library/azure/dn790546.aspx">docs</a> + */ + @Delegate + ResourceGroupApi getResourceGroupApi(); + + /** + * Provides access to the Job tracking API. + */ + @Delegate + JobApi getJobApi(); + + /** + * This Azure Resource Manager API provides all of the locations that are + * available for resource providers + * + * @see <a href= + * "https://msdn.microsoft.com/en-US/library/azure/dn790540.aspx">docs</a> + */ + @Delegate + LocationApi getLocationApi(); + + /** + * The Azure Resource Manager API includes operations for managing the storage + * accounts in your subscription. + * + * @see <https://msdn.microsoft.com/en-us/library/mt163683.aspx">docs</a> + */ + @Delegate + StorageAccountApi getStorageAccountApi(@PathParam("resourceGroup") String resourceGroup); + + /** + * The Subnet API includes operations for managing the subnets in your virtual + * network. + * + * @see <a href= + * "https://msdn.microsoft.com/en-us/library/azure/mt163621.aspx">docs</a> + */ + @Delegate + SubnetApi getSubnetApi(@PathParam("resourcegroup") String resourcegroup, + @PathParam("virtualnetwork") String virtualnetwork); + + /** + * The Virtual Network API includes operations for managing the virtual networks + * in your subscription. + * + * @see <a href= + * "https://msdn.microsoft.com/en-us/library/azure/mt163661.aspx">docs</a> + */ + @Delegate + VirtualNetworkApi getVirtualNetworkApi(@Nullable @PathParam("resourcegroup") String resourcegroup); + + /** + * The Network Interface Card API includes operations for managing the NICs in + * your subscription. + * + * @see <a href= + * "https://msdn.microsoft.com/en-us/library/mt163668.aspx">docs</a> + */ + @Delegate + NetworkInterfaceCardApi getNetworkInterfaceCardApi(@Nullable @PathParam("resourcegroup") String resourcegroup); + + /** + * The Public IP Address API includes operations for managing public ID + * Addresses for NICs in your subscription. + * + * @see <a href= + * "https://msdn.microsoft.com/en-us/library/azure/mt163638.aspx">docs</a> + */ + @Delegate + PublicIPAddressApi getPublicIPAddressApi(@Nullable @PathParam("resourcegroup") String resourcegroup); + + /** + * The Virtual Machine API includes operations for managing the virtual machines + * in your subscription. + * + * @see <a href= + * "https://msdn.microsoft.com/en-us/library/azure/mt163630.aspx">docs</a> + */ + @Delegate + VirtualMachineApi getVirtualMachineApi(@Nullable @PathParam("resourceGroup") String resourceGroup); + + /** + * The Virtual Machine Scale Set API includes operations for managing the + * virtual machines in your subscription. + * + * @see <a href= + * "https://msdn.microsoft.com/en-us/library/azure/mt163630.aspx">docs</a> + */ + @Delegate + VirtualMachineScaleSetApi getVirtualMachineScaleSetApi(@PathParam("resourceGroup") String resourceGroup); + + /** + * This Azure Resource Manager API lists all available virtual machine sizes for + * a subscription in a given region + * + * @see <a href= + * "https://msdn.microsoft.com/en-us/library/azure/mt269440.aspx">docs</a> + */ + @Delegate + VMSizeApi getVMSizeApi(@PathParam("location") String location); + + /** + * The Azure Resource Manager API gets all the OS images in your subscription. + * + * @see <a href= + * "https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages">docs</a> + */ + @Delegate + OSImageApi getOSImageApi(@PathParam("location") String location); + + /** + * The Deployment API allows for the management of Azure Resource Manager + * resources through the use of templates. + * + * @see <a href= + * "https://msdn.microsoft.com/en-us/library/azure/dn790549.aspx">docs</a> + */ + @Delegate + DeploymentApi getDeploymentApi(@PathParam("resourcegroup") String resourceGroup); + + /** + * The NetworkSecurityGroup API includes operations for managing network + * security groups within your subscription. + * + * @see <a href= + * "https://msdn.microsoft.com/en-us/library/azure/mt163615.aspx">docs</a> + */ + @Delegate + NetworkSecurityGroupApi getNetworkSecurityGroupApi(@Nullable @PathParam("resourcegroup") String resourcegroup); + + /** + * The NetworkSecurityRule API includes operations for managing network security + * rules within a network security group. + * + * @see <a href= + * "https://msdn.microsoft.com/en-us/library/azure/mt163580.aspx">docs</a> + */ + @Delegate + NetworkSecurityRuleApi getNetworkSecurityRuleApi(@PathParam("resourcegroup") String resourcegroup, + @PathParam("networksecuritygroup") String networksecuritygroup); + + /** + * The LoadBalancer API includes operations for managing load balancers within + * your subscription. + * + * @see <a href= + * "https://msdn.microsoft.com/en-us/library/azure/mt163574.aspx">docs </a> + */ + @Delegate + LoadBalancerApi getLoadBalancerApi(@Nullable @PathParam("resourcegroup") String resourcegroup); + + /** + * The AvailabilitySet API includes operations for managing availability sets + * within your subscription. + * + * @see <a href= + * "https://docs.microsoft.com/en-us/rest/api/compute/availabilitysets">docs + * </a> + */ + @Delegate + AvailabilitySetApi getAvailabilitySetApi(@PathParam("resourcegroup") String resourcegroup); + + /** + * The Azure Resource Provider API provides information about a resource + * provider and its supported resource types. + * + * @see <a href= + * "https://msdn.microsoft.com/en-us/library/azure/dn790534.aspx">docs</a> + */ + @Delegate + ResourceProviderApi getResourceProviderApi(); + + /** + * The ManagedDataDisk API includes operations for managing data disks within + * your subscription. + * + * @see <a href= + * "https://docs.microsoft.com/en-us/rest/api/manageddisks/disks/disks-rest-api">docs</a> + */ + @Delegate + DiskApi getDiskApi(@PathParam("resourcegroup") String resourcegroup); + + /** + * The virtual machine image API includes operations for managing data disks + * within your subscription. + * + * @see <a href= + * "https://docs.microsoft.com/en-us/rest/api/manageddisks/images/images-rest-api">docs</a> + */ + @Delegate + ImageApi getVirtualMachineImageApi(@PathParam("resourcegroup") String resourcegroup); + + /** + * The metrics API includes operations to get insights into entities within your + * subscription. + * + * @see <a href= + * "https://docs.microsoft.com/en-us/rest/api/monitor/metrics">docs</a> + */ + @Delegate + MetricsApi getMetricsApi(@PathParam("resourceid") String resourceid); + + /** + * The metric definitions API includes operations to get insights available for + * entities within your subscription. + * + * @see <a href= + * "https://docs.microsoft.com/en-us/rest/api/monitor/metricdefinitions">docs</a> + */ + @Delegate + MetricDefinitionsApi getMetricsDefinitionsApi(@PathParam("resourceid") String resourceid); + + /** + * The Azure Active Directory Graph API provides programmatic access to Azure AD + * through REST API endpoints. + * + * @see <a href="https://docs.microsoft.com/en-us/rest/api/graphrbac/">docs</a> + */ + @Delegate + GraphRBACApi getGraphRBACApi(); + + /** + * Managing your key vaults as well as the keys, secrets, and certificates + * within your key vaults can be accomplished through a REST interface. + * + * @see <a href="https://docs.microsoft.com/en-us/rest/api/keyvault/">docs</a> + */ + @Delegate + VaultApi getVaultApi(@PathParam("resourcegroup") String resourcegroup); + + /** + * Management features for Local Network Gateways. + * + * @see <a href= + * "https://docs.microsoft.com/en-us/rest/api/network-gateway/localnetworkgateways">docs</a> + */ + @Delegate + LocalNetworkGatewayApi getLocalNetworkGatewayApi(@PathParam("resourcegroup") String resourcegroup); + + /** + * Management features for Virtual Network Gateways. + * + * @see <a href= + * "https://docs.microsoft.com/en-us/rest/api/network-gateway/virtualnetworkgateways">docs</a> + */ + @Delegate + VirtualNetworkGatewayApi getVirtualNetworkGatewayApi(@PathParam("resourcegroup") String resourcegroup); + + /** + * Management features for Virtual Network Gateway Connections. + * + * @see <a href= + * "https://docs.microsoft.com/en-us/rest/api/network-gateway/virtualnetworkgatewayconnections">docs</a> + */ + @Delegate + VirtualNetworkGatewayConnectionApi getVirtualNetworkGatewayConnectionApi( + @PathParam("resourcegroup") String resourcegroup); + + /** + * Returns the information about the current service principal. + */ + @Provides + Supplier<ServicePrincipal> getServicePrincipal(); + + /** + * The Activity Log Alert API includes operations to get insights available for + * entities within your subscription + * + * @see <a href= + * "https://docs.microsoft.com/en-us/rest/api/monitor/activity-log-alerts">docs</a> + */ + @Delegate + ActivityLogAlertApi getActivityLogAlertApi(@PathParam("resourcegroup") String resourcegroup); } 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 274c738..5dbef36 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 @@ -39,6 +39,7 @@ import java.net.URI; import java.util.Properties; import org.jclouds.azurecompute.arm.domain.Region; +import org.jclouds.azurecompute.arm.features.ActivityLogAlertApi; import org.jclouds.azurecompute.arm.features.AvailabilitySetApi; import org.jclouds.azurecompute.arm.features.DeploymentApi; import org.jclouds.azurecompute.arm.features.DiskApi; @@ -136,6 +137,7 @@ public class AzureComputeProviderMetadata extends BaseProviderMetadata { properties.put(API_VERSION_PREFIX + LocalNetworkGatewayApi.class.getSimpleName(), "2018-02-01"); 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"); return properties; } diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ActionGroup.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ActionGroup.java new file mode 100644 index 0000000..e72b878 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ActionGroup.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 org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; + +@AutoValue +public abstract class ActionGroup { + @Nullable + public abstract String actionGroupId(); + + @Nullable + public abstract Object webhookProperties(); + + @SerializedNames({ "actionGroupId", "webhookProperties" }) + public static ActionGroup create(final String actionGroupId, final Object webhookProperties) { + return builder().actionGroupId(actionGroupId).webhookProperties(webhookProperties).build(); + } + + public abstract Builder toBuilder(); + + public static Builder builder() { + return new AutoValue_ActionGroup.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder actionGroupId(String actionGroupId); + + public abstract Builder webhookProperties(Object webhookProperties); + + public abstract ActionGroup build(); + + } +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Actions.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Actions.java new file mode 100644 index 0000000..e3e1d8e --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/Actions.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.domain; + +import com.google.auto.value.AutoValue; + +import java.util.List; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +@AutoValue +public abstract class Actions { + + @Nullable + public abstract List<ActionGroup> actionGroups(); + + @SerializedNames({ "actionGroups" }) + public static Actions create(final List<ActionGroup> actionGroups) { + return new AutoValue_Actions(actionGroups); + + } + +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ActivityLogAlert.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ActivityLogAlert.java new file mode 100644 index 0000000..3a9d530 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ActivityLogAlert.java @@ -0,0 +1,92 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.azurecompute.arm.domain; + +import java.util.Map; + +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.json.SerializedNames; + +import com.google.auto.value.AutoValue; +import com.google.common.collect.ImmutableMap; + +@AutoValue +public abstract class ActivityLogAlert { + + /** + * The id of the resource + */ + public abstract String id(); + + /** + * The name of the resource + */ + public abstract String name(); + + /** + * The location of the resource + */ + public abstract String location(); + + /** + * The type of the resource + */ + public abstract String type(); + + @Nullable + public abstract Map<String, String> tags(); + + @Nullable + public abstract ActivityLogAlertProperties properties(); + + @SerializedNames({ "id", "name", "location", "type", "tags", "properties" }) + public static ActivityLogAlert create(final String id, final String name, final String location, + final String type, final Map<String, String> tags, final ActivityLogAlertProperties properties) { + return builder().id(id).name(name).location(location).type(type).tags(tags).properties(properties).build(); + } + + public abstract Builder toBuilder(); + + public static Builder builder() { + return new AutoValue_ActivityLogAlert.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder id(String id); + + public abstract Builder name(String name); + + public abstract Builder location(String location); + + public abstract Builder type(String type); + + public abstract Builder tags(Map<String, String> tags); + + public abstract Builder properties(ActivityLogAlertProperties properties); + + abstract Map<String, String> tags(); + + abstract ActivityLogAlert autoBuild(); + + public ActivityLogAlert build() { + tags(tags() != null ? ImmutableMap.copyOf(tags()) : null); + return autoBuild(); + } + + } +} 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 new file mode 100644 index 0000000..6517d8c --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/ActivityLogAlertProperties.java @@ -0,0 +1,72 @@ +/* + * 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 ActivityLogAlertProperties { + + @Nullable + public abstract String description(); + + @Nullable + public abstract Boolean enabled(); + + @Nullable + public abstract List<String> scopes(); + + @Nullable + public abstract AlertRuleAllOfCondition condition(); + + @Nullable + public abstract Actions actions(); + + @SerializedNames({ "description", "enabled", "scopes", "condition", "actions" }) + 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(); + } + + public abstract Builder toBuilder(); + + public static Builder builder() { + return new AutoValue_ActivityLogAlertProperties.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder description(String description); + + public abstract Builder enabled(Boolean enabled); + + public abstract Builder scopes(List<String> scopes); + + public abstract Builder condition(AlertRuleAllOfCondition condition); + + public abstract Builder actions(Actions actions); + + public abstract ActivityLogAlertProperties build(); + + } +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertRuleAllOfCondition.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertRuleAllOfCondition.java new file mode 100644 index 0000000..2524953 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertRuleAllOfCondition.java @@ -0,0 +1,57 @@ +/* + * 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 AlertRuleAllOfCondition { + + @Nullable + public abstract List<AlertRuleAnyOfOrLeafCondition> allOf(); + + @Nullable + public abstract String odatatype(); + + @SerializedNames({ "allOf", "odata.type" }) + public static AlertRuleAllOfCondition create(final List<AlertRuleAnyOfOrLeafCondition> allOf, + final String odatatype) { + return builder().allOf(allOf).odatatype(odatatype).build(); + } + + public abstract Builder toBuilder(); + + public static Builder builder() { + return new AutoValue_AlertRuleAllOfCondition.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder allOf(List<AlertRuleAnyOfOrLeafCondition> allOf); + + public abstract Builder odatatype(String odatatype); + + public abstract AlertRuleAllOfCondition build(); + + } + +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertRuleAnyOfOrLeafCondition.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertRuleAnyOfOrLeafCondition.java new file mode 100644 index 0000000..de4e4c0 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertRuleAnyOfOrLeafCondition.java @@ -0,0 +1,67 @@ +/* + * 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 AlertRuleAnyOfOrLeafCondition { + + @Nullable + public abstract List<AlertRuleLeafCondition> anyOf(); + + @Nullable + public abstract List<String> containsAny(); + + @Nullable + public abstract String equals(); + + @Nullable + public abstract String field(); + + @SerializedNames({ "anyOf", "containsAny", "equals", "field" }) + public static AlertRuleAnyOfOrLeafCondition create(final List<AlertRuleLeafCondition> anyOf, + final List<String> containsAny, final String equals, final String field) { + return builder().anyOf(anyOf).containsAny(containsAny).equals(equals).field(field).build(); + } + + public abstract Builder toBuilder(); + + public static Builder builder() { + return new AutoValue_AlertRuleAnyOfOrLeafCondition.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + public abstract Builder anyOf(List<AlertRuleLeafCondition> anyOf); + + public abstract Builder containsAny(List<String> containsAny); + + public abstract Builder equals(String equals); + + public abstract Builder field(String field); + + public abstract AlertRuleAnyOfOrLeafCondition build(); + + } + +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertRuleLeafCondition.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertRuleLeafCondition.java new file mode 100644 index 0000000..7eba23a --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/domain/AlertRuleLeafCondition.java @@ -0,0 +1,63 @@ +/* + * 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 AlertRuleLeafCondition { + + @Nullable + public abstract List<String> containsAny(); + + @Nullable + public abstract String field(); + + @Nullable + public abstract String equals(); + + @SerializedNames({ "containsAny", "equals", "field" }) + public static AlertRuleLeafCondition create(final List<String> containsAny, final String equals, + final String field) { + return builder().containsAny(containsAny).equals(equals).field(field).build(); + } + + public abstract Builder toBuilder(); + + public static Builder builder() { + return new AutoValue_AlertRuleLeafCondition.Builder(); + } + + @AutoValue.Builder + public abstract static class Builder { + + public abstract Builder containsAny(List<String> containsAny); + + public abstract Builder equals(String equals); + + public abstract Builder field(String field); + + public abstract AlertRuleLeafCondition build(); + + } + +} diff --git a/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/ActivityLogAlertApi.java b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/ActivityLogAlertApi.java new file mode 100644 index 0000000..d0e9c80 --- /dev/null +++ b/providers/azurecompute-arm/src/main/java/org/jclouds/azurecompute/arm/features/ActivityLogAlertApi.java @@ -0,0 +1,87 @@ +/* + * 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.net.URI; +import java.util.List; +import java.util.Map; + +import javax.inject.Named; +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.MediaType; + +import org.jclouds.Fallbacks; +import org.jclouds.azurecompute.arm.domain.ActivityLogAlert; +import org.jclouds.azurecompute.arm.domain.ActivityLogAlertProperties; +import org.jclouds.azurecompute.arm.filters.ApiVersionFilter; +import org.jclouds.azurecompute.arm.functions.URIParser; +import org.jclouds.oauth.v2.filters.OAuthFilter; +import org.jclouds.rest.annotations.Fallback; +import org.jclouds.rest.annotations.MapBinder; +import org.jclouds.rest.annotations.PayloadParam; +import org.jclouds.rest.annotations.QueryParams; +import org.jclouds.rest.annotations.RequestFilters; +import org.jclouds.rest.annotations.ResponseParser; +import org.jclouds.rest.annotations.SelectJson; +import org.jclouds.rest.binders.BindToJsonPayload; + +/** + * The Activity Log Alert API includes operations for managing activity log type + * alert rules in your subscription. + * + * @see <a href= + * "https://docs.microsoft.com/en-us/rest/api/monitor/activity-log-alerts">docs</a> + */ +@Path("/resourcegroups/{resourcegroup}/providers/Microsoft.Insights/activityLogAlerts") +@RequestFilters({ OAuthFilter.class, ApiVersionFilter.class }) +@Consumes(MediaType.APPLICATION_JSON) +public interface ActivityLogAlertApi { + + @Named("activitylogalert:get") + @GET + @Path("/{name}") + @Fallback(Fallbacks.NullOnNotFoundOr404.class) + ActivityLogAlert get(@PathParam("name") String name); + + @Named("activitylogalert:list") + @GET + @SelectJson("value") + @Fallback(Fallbacks.EmptyListOnNotFoundOr404.class) + List<ActivityLogAlert> list(); + + @Named("activitylogalert:createOrUpdate") + @PUT + @MapBinder(BindToJsonPayload.class) + @Path("/{activityLogAlertName}") + @QueryParams(keys = "validating", values = "false") + ActivityLogAlert createOrUpdate(@PathParam("activityLogAlertName") String activityLogAlertName, + @PayloadParam("properties") ActivityLogAlertProperties properties, + @PayloadParam("tags") Map<String, String> tags, @PayloadParam("location") String location); + + @Named("activitylogalert:delete") + @DELETE + @Path("/{activityLogAlertName}") + @ResponseParser(URIParser.class) + @Fallback(Fallbacks.NullOnNotFoundOr404.class) + URI delete(@PathParam("activityLogAlertName") String activityLogAlertName); + +}
