diff --git a/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/Action.java b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/Action.java new file mode 100644 index 00000000000..e174b47cd5e --- /dev/null +++ b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/Action.java @@ -0,0 +1,70 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.monitor; + +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * An alert action. + */ +public class Action { + /** + * the id of the action group to use. + */ + @JsonProperty(value = "actionGroupId") + private String actionGroupId; + + /** + * The webhookProperties property. + */ + @JsonProperty(value = "webhookProperties") + private Map webhookProperties; + + /** + * Get the actionGroupId value. + * + * @return the actionGroupId value + */ + public String actionGroupId() { + return this.actionGroupId; + } + + /** + * Set the actionGroupId value. + * + * @param actionGroupId the actionGroupId value to set + * @return the Action object itself. + */ + public Action withActionGroupId(String actionGroupId) { + this.actionGroupId = actionGroupId; + return this; + } + + /** + * Get the webhookProperties value. + * + * @return the webhookProperties value + */ + public Map webhookProperties() { + return this.webhookProperties; + } + + /** + * Set the webhookProperties value. + * + * @param webhookProperties the webhookProperties value to set + * @return the Action object itself. + */ + public Action withWebhookProperties(Map webhookProperties) { + this.webhookProperties = webhookProperties; + return this; + } + +} diff --git a/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/AlertStatus.java b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/AlertStatus.java new file mode 100644 index 00000000000..14de61e2de6 --- /dev/null +++ b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/AlertStatus.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.monitor; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * An alert status. + */ +public class AlertStatus { + /** + * status value. + */ + @JsonProperty(value = "value") + private String value; + + /** + * UTC time when the status was checked. + */ + @JsonProperty(value = "timestamp") + private String timestamp; + + /** + * Get the value value. + * + * @return the value value + */ + public String value() { + return this.value; + } + + /** + * Set the value value. + * + * @param value the value value to set + * @return the AlertStatus object itself. + */ + public AlertStatus withValue(String value) { + this.value = value; + return this; + } + + /** + * Get the timestamp value. + * + * @return the timestamp value + */ + public String timestamp() { + return this.timestamp; + } + + /** + * Set the timestamp value. + * + * @param timestamp the timestamp value to set + * @return the AlertStatus object itself. + */ + public AlertStatus withTimestamp(String timestamp) { + this.timestamp = timestamp; + return this; + } + +} diff --git a/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/MetricAlertCriteria.java b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/MetricAlertCriteria.java new file mode 100644 index 00000000000..5e6b02bafcd --- /dev/null +++ b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/MetricAlertCriteria.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.monitor; + +import java.util.Map; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonSubTypes; + +/** + * The rule criteria that defines the conditions of the alert rule. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "odata.type") +@JsonTypeName("MetricAlertCriteria") +@JsonSubTypes({ + @JsonSubTypes.Type(name = "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria", value = MetricAlertSingleResourceMultipleMetricCriteria.class) +}) +public class MetricAlertCriteria { + /** + * Unmatched properties from the message are deserialized this collection. + */ + @JsonProperty(value = "") + private Map additionalProperties; + + /** + * Get the additionalProperties value. + * + * @return the additionalProperties value + */ + public Map additionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties value. + * + * @param additionalProperties the additionalProperties value to set + * @return the MetricAlertCriteria object itself. + */ + public MetricAlertCriteria withAdditionalProperties(Map additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + +} diff --git a/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/MetricAlertSingleResourceMultipleMetricCriteria.java b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/MetricAlertSingleResourceMultipleMetricCriteria.java new file mode 100644 index 00000000000..20d754b040f --- /dev/null +++ b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/MetricAlertSingleResourceMultipleMetricCriteria.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.monitor; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * Specifies the metric alert criteria for a single resource that has multiple + * metric criteria. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "odata.type") +@JsonTypeName("Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria") +public class MetricAlertSingleResourceMultipleMetricCriteria extends MetricAlertCriteria { + /** + * The list of metric criteria for this 'all of' operation. + */ + @JsonProperty(value = "allOf") + private List allOf; + + /** + * Get the allOf value. + * + * @return the allOf value + */ + public List allOf() { + return this.allOf; + } + + /** + * Set the allOf value. + * + * @param allOf the allOf value to set + * @return the MetricAlertSingleResourceMultipleMetricCriteria object itself. + */ + public MetricAlertSingleResourceMultipleMetricCriteria withAllOf(List allOf) { + this.allOf = allOf; + return this; + } + +} diff --git a/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/MetricAlertStatus.java b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/MetricAlertStatus.java new file mode 100644 index 00000000000..8a3fb875106 --- /dev/null +++ b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/MetricAlertStatus.java @@ -0,0 +1,121 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.monitor; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * An alert status. + */ +public class MetricAlertStatus { + /** + * The status name. + */ + @JsonProperty(value = "name") + private String name; + + /** + * The alert rule arm id. + */ + @JsonProperty(value = "id") + private String id; + + /** + * The extended resource type name. + */ + @JsonProperty(value = "type") + private String type; + + /** + * The alert status properties of the metric alert status. + */ + @JsonProperty(value = "properties") + private MetricAlertStatusProperties properties; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the MetricAlertStatus object itself. + */ + public MetricAlertStatus withName(String name) { + this.name = name; + return this; + } + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + + /** + * Set the id value. + * + * @param id the id value to set + * @return the MetricAlertStatus object itself. + */ + public MetricAlertStatus withId(String id) { + this.id = id; + return this; + } + + /** + * Get the type value. + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Set the type value. + * + * @param type the type value to set + * @return the MetricAlertStatus object itself. + */ + public MetricAlertStatus withType(String type) { + this.type = type; + return this; + } + + /** + * Get the properties value. + * + * @return the properties value + */ + public MetricAlertStatusProperties properties() { + return this.properties; + } + + /** + * Set the properties value. + * + * @param properties the properties value to set + * @return the MetricAlertStatus object itself. + */ + public MetricAlertStatus withProperties(MetricAlertStatusProperties properties) { + this.properties = properties; + return this; + } + +} diff --git a/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/MetricAlertStatusProperties.java b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/MetricAlertStatusProperties.java new file mode 100644 index 00000000000..94360c50133 --- /dev/null +++ b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/MetricAlertStatusProperties.java @@ -0,0 +1,97 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.monitor; + +import java.util.Map; +import org.joda.time.DateTime; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * An alert status properties. + */ +public class MetricAlertStatusProperties { + /** + * The dimensions property. + */ + @JsonProperty(value = "dimensions") + private Map dimensions; + + /** + * status value. + */ + @JsonProperty(value = "status") + private String status; + + /** + * UTC time when the status was checked. + */ + @JsonProperty(value = "timestamp") + private DateTime timestamp; + + /** + * Get the dimensions value. + * + * @return the dimensions value + */ + public Map dimensions() { + return this.dimensions; + } + + /** + * Set the dimensions value. + * + * @param dimensions the dimensions value to set + * @return the MetricAlertStatusProperties object itself. + */ + public MetricAlertStatusProperties withDimensions(Map dimensions) { + this.dimensions = dimensions; + return this; + } + + /** + * Get the status value. + * + * @return the status value + */ + public String status() { + return this.status; + } + + /** + * Set the status value. + * + * @param status the status value to set + * @return the MetricAlertStatusProperties object itself. + */ + public MetricAlertStatusProperties withStatus(String status) { + this.status = status; + return this; + } + + /** + * Get the timestamp value. + * + * @return the timestamp value + */ + public DateTime timestamp() { + return this.timestamp; + } + + /** + * Set the timestamp value. + * + * @param timestamp the timestamp value to set + * @return the MetricAlertStatusProperties object itself. + */ + public MetricAlertStatusProperties withTimestamp(DateTime timestamp) { + this.timestamp = timestamp; + return this; + } + +} diff --git a/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/MetricCriteria.java b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/MetricCriteria.java new file mode 100644 index 00000000000..c5b0ce6869c --- /dev/null +++ b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/MetricCriteria.java @@ -0,0 +1,200 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.monitor; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The MetricCriteria model. + */ +public class MetricCriteria { + /** + * Name of the criteria. + */ + @JsonProperty(value = "name", required = true) + private String name; + + /** + * Name of the metric. + */ + @JsonProperty(value = "metricName", required = true) + private String metricName; + + /** + * Namespace of the metric. + */ + @JsonProperty(value = "metricNamespace") + private String metricNamespace; + + /** + * the criteria operator. + */ + @JsonProperty(value = "operator", required = true) + private Object operator; + + /** + * the criteria time aggregation types. + */ + @JsonProperty(value = "timeAggregation", required = true) + private Object timeAggregation; + + /** + * the criteria threshold value that activates the alert. + */ + @JsonProperty(value = "threshold", required = true) + private double threshold; + + /** + * List of dimension conditions. + */ + @JsonProperty(value = "dimensions") + private List dimensions; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the MetricCriteria object itself. + */ + public MetricCriteria withName(String name) { + this.name = name; + return this; + } + + /** + * Get the metricName value. + * + * @return the metricName value + */ + public String metricName() { + return this.metricName; + } + + /** + * Set the metricName value. + * + * @param metricName the metricName value to set + * @return the MetricCriteria object itself. + */ + public MetricCriteria withMetricName(String metricName) { + this.metricName = metricName; + return this; + } + + /** + * Get the metricNamespace value. + * + * @return the metricNamespace value + */ + public String metricNamespace() { + return this.metricNamespace; + } + + /** + * Set the metricNamespace value. + * + * @param metricNamespace the metricNamespace value to set + * @return the MetricCriteria object itself. + */ + public MetricCriteria withMetricNamespace(String metricNamespace) { + this.metricNamespace = metricNamespace; + return this; + } + + /** + * Get the operator value. + * + * @return the operator value + */ + public Object operator() { + return this.operator; + } + + /** + * Set the operator value. + * + * @param operator the operator value to set + * @return the MetricCriteria object itself. + */ + public MetricCriteria withOperator(Object operator) { + this.operator = operator; + return this; + } + + /** + * Get the timeAggregation value. + * + * @return the timeAggregation value + */ + public Object timeAggregation() { + return this.timeAggregation; + } + + /** + * Set the timeAggregation value. + * + * @param timeAggregation the timeAggregation value to set + * @return the MetricCriteria object itself. + */ + public MetricCriteria withTimeAggregation(Object timeAggregation) { + this.timeAggregation = timeAggregation; + return this; + } + + /** + * Get the threshold value. + * + * @return the threshold value + */ + public double threshold() { + return this.threshold; + } + + /** + * Set the threshold value. + * + * @param threshold the threshold value to set + * @return the MetricCriteria object itself. + */ + public MetricCriteria withThreshold(double threshold) { + this.threshold = threshold; + return this; + } + + /** + * Get the dimensions value. + * + * @return the dimensions value + */ + public List dimensions() { + return this.dimensions; + } + + /** + * Set the dimensions value. + * + * @param dimensions the dimensions value to set + * @return the MetricCriteria object itself. + */ + public MetricCriteria withDimensions(List dimensions) { + this.dimensions = dimensions; + return this; + } + +} diff --git a/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/MetricDimension.java b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/MetricDimension.java new file mode 100644 index 00000000000..3309c284328 --- /dev/null +++ b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/MetricDimension.java @@ -0,0 +1,96 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.monitor; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The MetricDimension model. + */ +public class MetricDimension { + /** + * Name of the dimension. + */ + @JsonProperty(value = "name", required = true) + private String name; + + /** + * the dimension operator. + */ + @JsonProperty(value = "operator", required = true) + private String operator; + + /** + * list of dimension values. + */ + @JsonProperty(value = "values", required = true) + private List values; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name value. + * + * @param name the name value to set + * @return the MetricDimension object itself. + */ + public MetricDimension withName(String name) { + this.name = name; + return this; + } + + /** + * Get the operator value. + * + * @return the operator value + */ + public String operator() { + return this.operator; + } + + /** + * Set the operator value. + * + * @param operator the operator value to set + * @return the MetricDimension object itself. + */ + public MetricDimension withOperator(String operator) { + this.operator = operator; + return this; + } + + /** + * Get the values value. + * + * @return the values value + */ + public List values() { + return this.values; + } + + /** + * Set the values value. + * + * @param values the values value to set + * @return the MetricDimension object itself. + */ + public MetricDimension withValues(List values) { + this.values = values; + return this; + } + +} diff --git a/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/implementation/MetricAlertResourceInner.java b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/implementation/MetricAlertResourceInner.java new file mode 100644 index 00000000000..d646967537b --- /dev/null +++ b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/implementation/MetricAlertResourceInner.java @@ -0,0 +1,252 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.monitor.implementation; + +import java.util.List; +import org.joda.time.Period; +import com.microsoft.azure.management.monitor.MetricAlertCriteria; +import com.microsoft.azure.management.monitor.Action; +import org.joda.time.DateTime; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; +import com.microsoft.azure.Resource; + +/** + * The metric alert resource. + */ +@JsonFlatten +public class MetricAlertResourceInner extends Resource { + /** + * the description of the metric alert that will be included in the alert + * email. + */ + @JsonProperty(value = "properties.description", required = true) + private String description; + + /** + * Alert severity {0, 1, 2, 3, 4}. + */ + @JsonProperty(value = "properties.severity", required = true) + private int severity; + + /** + * the flag that indicates whether the metric alert is enabled. + */ + @JsonProperty(value = "properties.enabled", required = true) + private boolean enabled; + + /** + * the list of resource id's that this metric alert is scoped to. + */ + @JsonProperty(value = "properties.scopes") + private List scopes; + + /** + * how often the metric alert is evaluated represented in ISO 8601 duration + * format. + */ + @JsonProperty(value = "properties.evaluationFrequency", required = true) + private Period evaluationFrequency; + + /** + * the period of time (in ISO 8601 duration format) that is used to monitor + * alert activity based on the threshold. + */ + @JsonProperty(value = "properties.windowSize", required = true) + private Period windowSize; + + /** + * defines the specific alert criteria information. + */ + @JsonProperty(value = "properties.criteria", required = true) + private MetricAlertCriteria criteria; + + /** + * the array of actions that are performed when the alert rule becomes + * active, and when an alert condition is resolved. + */ + @JsonProperty(value = "properties.actions") + private List actions; + + /** + * Last time the rule was updated in ISO8601 format. + */ + @JsonProperty(value = "properties.lastUpdatedTime", access = JsonProperty.Access.WRITE_ONLY) + private DateTime lastUpdatedTime; + + /** + * Get the description value. + * + * @return the description value + */ + public String description() { + return this.description; + } + + /** + * Set the description value. + * + * @param description the description value to set + * @return the MetricAlertResourceInner object itself. + */ + public MetricAlertResourceInner withDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the severity value. + * + * @return the severity value + */ + public int severity() { + return this.severity; + } + + /** + * Set the severity value. + * + * @param severity the severity value to set + * @return the MetricAlertResourceInner object itself. + */ + public MetricAlertResourceInner withSeverity(int severity) { + this.severity = severity; + return this; + } + + /** + * Get the enabled value. + * + * @return the enabled value + */ + public boolean enabled() { + return this.enabled; + } + + /** + * Set the enabled value. + * + * @param enabled the enabled value to set + * @return the MetricAlertResourceInner object itself. + */ + public MetricAlertResourceInner withEnabled(boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Get the scopes value. + * + * @return the scopes value + */ + public List scopes() { + return this.scopes; + } + + /** + * Set the scopes value. + * + * @param scopes the scopes value to set + * @return the MetricAlertResourceInner object itself. + */ + public MetricAlertResourceInner withScopes(List scopes) { + this.scopes = scopes; + return this; + } + + /** + * Get the evaluationFrequency value. + * + * @return the evaluationFrequency value + */ + public Period evaluationFrequency() { + return this.evaluationFrequency; + } + + /** + * Set the evaluationFrequency value. + * + * @param evaluationFrequency the evaluationFrequency value to set + * @return the MetricAlertResourceInner object itself. + */ + public MetricAlertResourceInner withEvaluationFrequency(Period evaluationFrequency) { + this.evaluationFrequency = evaluationFrequency; + return this; + } + + /** + * Get the windowSize value. + * + * @return the windowSize value + */ + public Period windowSize() { + return this.windowSize; + } + + /** + * Set the windowSize value. + * + * @param windowSize the windowSize value to set + * @return the MetricAlertResourceInner object itself. + */ + public MetricAlertResourceInner withWindowSize(Period windowSize) { + this.windowSize = windowSize; + return this; + } + + /** + * Get the criteria value. + * + * @return the criteria value + */ + public MetricAlertCriteria criteria() { + return this.criteria; + } + + /** + * Set the criteria value. + * + * @param criteria the criteria value to set + * @return the MetricAlertResourceInner object itself. + */ + public MetricAlertResourceInner withCriteria(MetricAlertCriteria criteria) { + this.criteria = criteria; + return this; + } + + /** + * Get the actions value. + * + * @return the actions value + */ + public List actions() { + return this.actions; + } + + /** + * Set the actions value. + * + * @param actions the actions value to set + * @return the MetricAlertResourceInner object itself. + */ + public MetricAlertResourceInner withActions(List actions) { + this.actions = actions; + return this; + } + + /** + * Get the lastUpdatedTime value. + * + * @return the lastUpdatedTime value + */ + public DateTime lastUpdatedTime() { + return this.lastUpdatedTime; + } + +} diff --git a/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/implementation/MetricAlertResourcePatchInner.java b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/implementation/MetricAlertResourcePatchInner.java new file mode 100644 index 00000000000..d6ece9bfa04 --- /dev/null +++ b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/implementation/MetricAlertResourcePatchInner.java @@ -0,0 +1,278 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.monitor.implementation; + +import java.util.Map; +import java.util.List; +import org.joda.time.Period; +import com.microsoft.azure.management.monitor.MetricAlertCriteria; +import com.microsoft.azure.management.monitor.Action; +import org.joda.time.DateTime; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.microsoft.rest.serializer.JsonFlatten; + +/** + * The metric alert resource for patch operations. + */ +@JsonFlatten +public class MetricAlertResourcePatchInner { + /** + * Resource tags. + */ + @JsonProperty(value = "tags") + private Map tags; + + /** + * the description of the metric alert that will be included in the alert + * email. + */ + @JsonProperty(value = "properties.description", required = true) + private String description; + + /** + * Alert severity {0, 1, 2, 3, 4}. + */ + @JsonProperty(value = "properties.severity", required = true) + private int severity; + + /** + * the flag that indicates whether the metric alert is enabled. + */ + @JsonProperty(value = "properties.enabled", required = true) + private boolean enabled; + + /** + * the list of resource id's that this metric alert is scoped to. + */ + @JsonProperty(value = "properties.scopes") + private List scopes; + + /** + * how often the metric alert is evaluated represented in ISO 8601 duration + * format. + */ + @JsonProperty(value = "properties.evaluationFrequency", required = true) + private Period evaluationFrequency; + + /** + * the period of time (in ISO 8601 duration format) that is used to monitor + * alert activity based on the threshold. + */ + @JsonProperty(value = "properties.windowSize", required = true) + private Period windowSize; + + /** + * defines the specific alert criteria information. + */ + @JsonProperty(value = "properties.criteria", required = true) + private MetricAlertCriteria criteria; + + /** + * the array of actions that are performed when the alert rule becomes + * active, and when an alert condition is resolved. + */ + @JsonProperty(value = "properties.actions") + private List actions; + + /** + * Last time the rule was updated in ISO8601 format. + */ + @JsonProperty(value = "properties.lastUpdatedTime", access = JsonProperty.Access.WRITE_ONLY) + private DateTime lastUpdatedTime; + + /** + * Get the tags value. + * + * @return the tags value + */ + public Map tags() { + return this.tags; + } + + /** + * Set the tags value. + * + * @param tags the tags value to set + * @return the MetricAlertResourcePatchInner object itself. + */ + public MetricAlertResourcePatchInner withTags(Map tags) { + this.tags = tags; + return this; + } + + /** + * Get the description value. + * + * @return the description value + */ + public String description() { + return this.description; + } + + /** + * Set the description value. + * + * @param description the description value to set + * @return the MetricAlertResourcePatchInner object itself. + */ + public MetricAlertResourcePatchInner withDescription(String description) { + this.description = description; + return this; + } + + /** + * Get the severity value. + * + * @return the severity value + */ + public int severity() { + return this.severity; + } + + /** + * Set the severity value. + * + * @param severity the severity value to set + * @return the MetricAlertResourcePatchInner object itself. + */ + public MetricAlertResourcePatchInner withSeverity(int severity) { + this.severity = severity; + return this; + } + + /** + * Get the enabled value. + * + * @return the enabled value + */ + public boolean enabled() { + return this.enabled; + } + + /** + * Set the enabled value. + * + * @param enabled the enabled value to set + * @return the MetricAlertResourcePatchInner object itself. + */ + public MetricAlertResourcePatchInner withEnabled(boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Get the scopes value. + * + * @return the scopes value + */ + public List scopes() { + return this.scopes; + } + + /** + * Set the scopes value. + * + * @param scopes the scopes value to set + * @return the MetricAlertResourcePatchInner object itself. + */ + public MetricAlertResourcePatchInner withScopes(List scopes) { + this.scopes = scopes; + return this; + } + + /** + * Get the evaluationFrequency value. + * + * @return the evaluationFrequency value + */ + public Period evaluationFrequency() { + return this.evaluationFrequency; + } + + /** + * Set the evaluationFrequency value. + * + * @param evaluationFrequency the evaluationFrequency value to set + * @return the MetricAlertResourcePatchInner object itself. + */ + public MetricAlertResourcePatchInner withEvaluationFrequency(Period evaluationFrequency) { + this.evaluationFrequency = evaluationFrequency; + return this; + } + + /** + * Get the windowSize value. + * + * @return the windowSize value + */ + public Period windowSize() { + return this.windowSize; + } + + /** + * Set the windowSize value. + * + * @param windowSize the windowSize value to set + * @return the MetricAlertResourcePatchInner object itself. + */ + public MetricAlertResourcePatchInner withWindowSize(Period windowSize) { + this.windowSize = windowSize; + return this; + } + + /** + * Get the criteria value. + * + * @return the criteria value + */ + public MetricAlertCriteria criteria() { + return this.criteria; + } + + /** + * Set the criteria value. + * + * @param criteria the criteria value to set + * @return the MetricAlertResourcePatchInner object itself. + */ + public MetricAlertResourcePatchInner withCriteria(MetricAlertCriteria criteria) { + this.criteria = criteria; + return this; + } + + /** + * Get the actions value. + * + * @return the actions value + */ + public List actions() { + return this.actions; + } + + /** + * Set the actions value. + * + * @param actions the actions value to set + * @return the MetricAlertResourcePatchInner object itself. + */ + public MetricAlertResourcePatchInner withActions(List actions) { + this.actions = actions; + return this; + } + + /** + * Get the lastUpdatedTime value. + * + * @return the lastUpdatedTime value + */ + public DateTime lastUpdatedTime() { + return this.lastUpdatedTime; + } + +} diff --git a/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/implementation/MetricAlertStatusCollectionInner.java b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/implementation/MetricAlertStatusCollectionInner.java new file mode 100644 index 00000000000..de139575806 --- /dev/null +++ b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/implementation/MetricAlertStatusCollectionInner.java @@ -0,0 +1,45 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.monitor.implementation; + +import java.util.List; +import com.microsoft.azure.management.monitor.MetricAlertStatus; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Represents a collection of alert rule resources. + */ +public class MetricAlertStatusCollectionInner { + /** + * the values for the alert rule resources. + */ + @JsonProperty(value = "value") + private List value; + + /** + * Get the value value. + * + * @return the value value + */ + public List value() { + return this.value; + } + + /** + * Set the value value. + * + * @param value the value value to set + * @return the MetricAlertStatusCollectionInner object itself. + */ + public MetricAlertStatusCollectionInner withValue(List value) { + this.value = value; + return this; + } + +} diff --git a/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/implementation/MetricAlertsInner.java b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/implementation/MetricAlertsInner.java new file mode 100644 index 00000000000..b77ed8139da --- /dev/null +++ b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/implementation/MetricAlertsInner.java @@ -0,0 +1,601 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.monitor.implementation; + +import com.microsoft.azure.management.resources.fluentcore.collection.InnerSupportsGet; +import com.microsoft.azure.management.resources.fluentcore.collection.InnerSupportsDelete; +import com.microsoft.azure.management.resources.fluentcore.collection.InnerSupportsListing; +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.CloudException; +import com.microsoft.azure.management.monitor.ErrorResponseException; +import com.microsoft.azure.Page; +import com.microsoft.azure.PagedList; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.IOException; +import java.util.List; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.HTTP; +import retrofit2.http.PATCH; +import retrofit2.http.Path; +import retrofit2.http.PUT; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in MetricAlerts. + */ +public class MetricAlertsInner implements InnerSupportsGet, InnerSupportsDelete, InnerSupportsListing { + /** The Retrofit service to perform REST calls. */ + private MetricAlertsService service; + /** The service client containing this operation class. */ + private MonitorManagementClientImpl client; + + /** + * Initializes an instance of MetricAlertsInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public MetricAlertsInner(Retrofit retrofit, MonitorManagementClientImpl client) { + this.service = retrofit.create(MetricAlertsService.class); + this.client = client; + } + + /** + * The interface defining all the services for MetricAlerts to be + * used by Retrofit to perform actually REST calls. + */ + interface MetricAlertsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.monitor.MetricAlerts list" }) + @GET("subscriptions/{subscriptionId}/providers/Microsoft.Insight/metricAlerts") + Observable> list(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.monitor.MetricAlerts listByResourceGroup" }) + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insight/metricAlerts") + Observable> listByResourceGroup(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.monitor.MetricAlerts getByResourceGroup" }) + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insight/metricAlerts/{ruleName}") + Observable> getByResourceGroup(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("ruleName") String ruleName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.monitor.MetricAlerts createOrUpdate" }) + @PUT("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insight/metricAlerts/{ruleName}") + Observable> createOrUpdate(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("ruleName") String ruleName, @Query("api-version") String apiVersion, @Body MetricAlertResourceInner parameters, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.monitor.MetricAlerts update" }) + @PATCH("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insight/metricAlerts/{ruleName}") + Observable> update(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("ruleName") String ruleName, @Query("api-version") String apiVersion, @Body MetricAlertResourcePatchInner parameters, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.monitor.MetricAlerts delete" }) + @HTTP(path = "subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insight/metricAlerts/{ruleName}", method = "DELETE", hasBody = true) + Observable> delete(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("ruleName") String ruleName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Retrieve alert rule definitions in a subscription. + * + * @return the PagedList object if successful. + */ + public PagedList list() { + PageImpl1 page = new PageImpl1<>(); + page.setItems(listWithServiceResponseAsync().toBlocking().single().body()); + page.setNextPageLink(null); + return new PagedList(page) { + @Override + public Page nextPage(String nextPageLink) { + return null; + } + }; + } + + /** + * Retrieve alert rule definitions in a subscription. + * + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listAsync(final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(), serviceCallback); + } + + /** + * Retrieve alert rule definitions in a subscription. + * + * @return the observable to the List<MetricAlertResourceInner> object + */ + public Observable> listAsync() { + return listWithServiceResponseAsync().map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + PageImpl1 page = new PageImpl1<>(); + page.setItems(response.body()); + return page; + } + }); + } + + /** + * Retrieve alert rule definitions in a subscription. + * + * @return the observable to the List<MetricAlertResourceInner> object + */ + public Observable>> listWithServiceResponseAsync() { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + final String apiVersion = "2018-03-01"; + return service.list(this.client.subscriptionId(), apiVersion, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listDelegate(response); + ServiceResponse> clientResponse = new ServiceResponse>(result.body().items(), result.response()); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Retrieve alert rule defintions in a resource group. + * + * @param resourceGroupName The name of the resource group. + * @return the PagedList object if successful. + */ + public PagedList listByResourceGroup(String resourceGroupName) { + PageImpl1 page = new PageImpl1<>(); + page.setItems(listByResourceGroupWithServiceResponseAsync(resourceGroupName).toBlocking().single().body()); + page.setNextPageLink(null); + return new PagedList(page) { + @Override + public Page nextPage(String nextPageLink) { + return null; + } + }; + } + + /** + * Retrieve alert rule defintions in a resource group. + * + * @param resourceGroupName The name of the resource group. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link ServiceFuture} object + */ + public ServiceFuture> listByResourceGroupAsync(String resourceGroupName, final ServiceCallback> serviceCallback) { + return ServiceFuture.fromResponse(listByResourceGroupWithServiceResponseAsync(resourceGroupName), serviceCallback); + } + + /** + * Retrieve alert rule defintions in a resource group. + * + * @param resourceGroupName The name of the resource group. + * @return the observable to the List<MetricAlertResourceInner> object + */ + public Observable> listByResourceGroupAsync(String resourceGroupName) { + return listByResourceGroupWithServiceResponseAsync(resourceGroupName).map(new Func1>, Page>() { + @Override + public Page call(ServiceResponse> response) { + PageImpl1 page = new PageImpl1<>(); + page.setItems(response.body()); + return page; + } + }); + } + + /** + * Retrieve alert rule defintions in a resource group. + * + * @param resourceGroupName The name of the resource group. + * @return the observable to the List<MetricAlertResourceInner> object + */ + public Observable>> listByResourceGroupWithServiceResponseAsync(String resourceGroupName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + final String apiVersion = "2018-03-01"; + return service.listByResourceGroup(this.client.subscriptionId(), resourceGroupName, apiVersion, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>>() { + @Override + public Observable>> call(Response response) { + try { + ServiceResponse> result = listByResourceGroupDelegate(response); + ServiceResponse> clientResponse = new ServiceResponse>(result.body().items(), result.response()); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse> listByResourceGroupDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory()., ErrorResponseException>newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken>() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Retrieve an alert rule definiton. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the MetricAlertResourceInner object if successful. + */ + public MetricAlertResourceInner getByResourceGroup(String resourceGroupName, String ruleName) { + return getByResourceGroupWithServiceResponseAsync(resourceGroupName, ruleName).toBlocking().single().body(); + } + + /** + * Retrieve an alert rule definiton. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture getByResourceGroupAsync(String resourceGroupName, String ruleName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getByResourceGroupWithServiceResponseAsync(resourceGroupName, ruleName), serviceCallback); + } + + /** + * Retrieve an alert rule definiton. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the MetricAlertResourceInner object + */ + public Observable getByResourceGroupAsync(String resourceGroupName, String ruleName) { + return getByResourceGroupWithServiceResponseAsync(resourceGroupName, ruleName).map(new Func1, MetricAlertResourceInner>() { + @Override + public MetricAlertResourceInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieve an alert rule definiton. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the MetricAlertResourceInner object + */ + public Observable> getByResourceGroupWithServiceResponseAsync(String resourceGroupName, String ruleName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (ruleName == null) { + throw new IllegalArgumentException("Parameter ruleName is required and cannot be null."); + } + final String apiVersion = "2018-03-01"; + return service.getByResourceGroup(this.client.subscriptionId(), resourceGroupName, ruleName, apiVersion, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getByResourceGroupDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getByResourceGroupDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Create or update an metric alert definition. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to create or update. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the MetricAlertResourceInner object if successful. + */ + public MetricAlertResourceInner createOrUpdate(String resourceGroupName, String ruleName, MetricAlertResourceInner parameters) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, ruleName, parameters).toBlocking().single().body(); + } + + /** + * Create or update an metric alert definition. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to create or update. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture createOrUpdateAsync(String resourceGroupName, String ruleName, MetricAlertResourceInner parameters, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(createOrUpdateWithServiceResponseAsync(resourceGroupName, ruleName, parameters), serviceCallback); + } + + /** + * Create or update an metric alert definition. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to create or update. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the MetricAlertResourceInner object + */ + public Observable createOrUpdateAsync(String resourceGroupName, String ruleName, MetricAlertResourceInner parameters) { + return createOrUpdateWithServiceResponseAsync(resourceGroupName, ruleName, parameters).map(new Func1, MetricAlertResourceInner>() { + @Override + public MetricAlertResourceInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Create or update an metric alert definition. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to create or update. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the MetricAlertResourceInner object + */ + public Observable> createOrUpdateWithServiceResponseAsync(String resourceGroupName, String ruleName, MetricAlertResourceInner parameters) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (ruleName == null) { + throw new IllegalArgumentException("Parameter ruleName is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + Validator.validate(parameters); + final String apiVersion = "2018-03-01"; + return service.createOrUpdate(this.client.subscriptionId(), resourceGroupName, ruleName, apiVersion, parameters, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = createOrUpdateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse createOrUpdateDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Update an metric alert definition. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to update. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the MetricAlertResourceInner object if successful. + */ + public MetricAlertResourceInner update(String resourceGroupName, String ruleName, MetricAlertResourcePatchInner parameters) { + return updateWithServiceResponseAsync(resourceGroupName, ruleName, parameters).toBlocking().single().body(); + } + + /** + * Update an metric alert definition. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to update. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture updateAsync(String resourceGroupName, String ruleName, MetricAlertResourcePatchInner parameters, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateWithServiceResponseAsync(resourceGroupName, ruleName, parameters), serviceCallback); + } + + /** + * Update an metric alert definition. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to update. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the MetricAlertResourceInner object + */ + public Observable updateAsync(String resourceGroupName, String ruleName, MetricAlertResourcePatchInner parameters) { + return updateWithServiceResponseAsync(resourceGroupName, ruleName, parameters).map(new Func1, MetricAlertResourceInner>() { + @Override + public MetricAlertResourceInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Update an metric alert definition. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @param parameters The parameters of the rule to update. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the MetricAlertResourceInner object + */ + public Observable> updateWithServiceResponseAsync(String resourceGroupName, String ruleName, MetricAlertResourcePatchInner parameters) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (ruleName == null) { + throw new IllegalArgumentException("Parameter ruleName is required and cannot be null."); + } + if (parameters == null) { + throw new IllegalArgumentException("Parameter parameters is required and cannot be null."); + } + Validator.validate(parameters); + final String apiVersion = "2018-03-01"; + return service.update(this.client.subscriptionId(), resourceGroupName, ruleName, apiVersion, parameters, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse updateDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Delete an alert rule defitiniton. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws CloudException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + */ + public void delete(String resourceGroupName, String ruleName) { + deleteWithServiceResponseAsync(resourceGroupName, ruleName).toBlocking().single().body(); + } + + /** + * Delete an alert rule defitiniton. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture deleteAsync(String resourceGroupName, String ruleName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(deleteWithServiceResponseAsync(resourceGroupName, ruleName), serviceCallback); + } + + /** + * Delete an alert rule defitiniton. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable deleteAsync(String resourceGroupName, String ruleName) { + return deleteWithServiceResponseAsync(resourceGroupName, ruleName).map(new Func1, Void>() { + @Override + public Void call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Delete an alert rule defitiniton. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceResponse} object if successful. + */ + public Observable> deleteWithServiceResponseAsync(String resourceGroupName, String ruleName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (ruleName == null) { + throw new IllegalArgumentException("Parameter ruleName is required and cannot be null."); + } + final String apiVersion = "2018-03-01"; + return service.delete(this.client.subscriptionId(), resourceGroupName, ruleName, apiVersion, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = deleteDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse deleteDelegate(Response response) throws CloudException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .register(204, new TypeToken() { }.getType()) + .registerError(CloudException.class) + .build(response); + } + +} diff --git a/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/implementation/MetricAlertsStatusInner.java b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/implementation/MetricAlertsStatusInner.java new file mode 100644 index 00000000000..ebe0f2f6c27 --- /dev/null +++ b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/implementation/MetricAlertsStatusInner.java @@ -0,0 +1,239 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.management.monitor.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.management.monitor.ErrorResponseException; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import okhttp3.ResponseBody; +import retrofit2.http.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in MetricAlertsStatus. + */ +public class MetricAlertsStatusInner { + /** The Retrofit service to perform REST calls. */ + private MetricAlertsStatusService service; + /** The service client containing this operation class. */ + private MonitorManagementClientImpl client; + + /** + * Initializes an instance of MetricAlertsStatusInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public MetricAlertsStatusInner(Retrofit retrofit, MonitorManagementClientImpl client) { + this.service = retrofit.create(MetricAlertsStatusService.class); + this.client = client; + } + + /** + * The interface defining all the services for MetricAlertsStatus to be + * used by Retrofit to perform actually REST calls. + */ + interface MetricAlertsStatusService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.monitor.MetricAlertsStatus list" }) + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insight/metricAlerts/{ruleName}/status") + Observable> list(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("ruleName") String ruleName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.monitor.MetricAlertsStatus listByName" }) + @GET("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insight/metricAlerts/{ruleName}/status/{statusName}") + Observable> listByName(@Path("subscriptionId") String subscriptionId, @Path("resourceGroupName") String resourceGroupName, @Path("ruleName") String ruleName, @Path("statusName") String statusName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Retrieve an alert rule status. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the MetricAlertStatusCollectionInner object if successful. + */ + public MetricAlertStatusCollectionInner list(String resourceGroupName, String ruleName) { + return listWithServiceResponseAsync(resourceGroupName, ruleName).toBlocking().single().body(); + } + + /** + * Retrieve an alert rule status. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture listAsync(String resourceGroupName, String ruleName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(listWithServiceResponseAsync(resourceGroupName, ruleName), serviceCallback); + } + + /** + * Retrieve an alert rule status. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the MetricAlertStatusCollectionInner object + */ + public Observable listAsync(String resourceGroupName, String ruleName) { + return listWithServiceResponseAsync(resourceGroupName, ruleName).map(new Func1, MetricAlertStatusCollectionInner>() { + @Override + public MetricAlertStatusCollectionInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieve an alert rule status. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the MetricAlertStatusCollectionInner object + */ + public Observable> listWithServiceResponseAsync(String resourceGroupName, String ruleName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (ruleName == null) { + throw new IllegalArgumentException("Parameter ruleName is required and cannot be null."); + } + final String apiVersion = "2018-03-01"; + return service.list(this.client.subscriptionId(), resourceGroupName, ruleName, apiVersion, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = listDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse listDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Retrieve an alert rule status. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @param statusName The name of the status. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the MetricAlertStatusCollectionInner object if successful. + */ + public MetricAlertStatusCollectionInner listByName(String resourceGroupName, String ruleName, String statusName) { + return listByNameWithServiceResponseAsync(resourceGroupName, ruleName, statusName).toBlocking().single().body(); + } + + /** + * Retrieve an alert rule status. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @param statusName The name of the status. + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture listByNameAsync(String resourceGroupName, String ruleName, String statusName, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(listByNameWithServiceResponseAsync(resourceGroupName, ruleName, statusName), serviceCallback); + } + + /** + * Retrieve an alert rule status. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @param statusName The name of the status. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the MetricAlertStatusCollectionInner object + */ + public Observable listByNameAsync(String resourceGroupName, String ruleName, String statusName) { + return listByNameWithServiceResponseAsync(resourceGroupName, ruleName, statusName).map(new Func1, MetricAlertStatusCollectionInner>() { + @Override + public MetricAlertStatusCollectionInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Retrieve an alert rule status. + * + * @param resourceGroupName The name of the resource group. + * @param ruleName The name of the rule. + * @param statusName The name of the status. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the MetricAlertStatusCollectionInner object + */ + public Observable> listByNameWithServiceResponseAsync(String resourceGroupName, String ruleName, String statusName) { + if (this.client.subscriptionId() == null) { + throw new IllegalArgumentException("Parameter this.client.subscriptionId() is required and cannot be null."); + } + if (resourceGroupName == null) { + throw new IllegalArgumentException("Parameter resourceGroupName is required and cannot be null."); + } + if (ruleName == null) { + throw new IllegalArgumentException("Parameter ruleName is required and cannot be null."); + } + if (statusName == null) { + throw new IllegalArgumentException("Parameter statusName is required and cannot be null."); + } + final String apiVersion = "2018-03-01"; + return service.listByName(this.client.subscriptionId(), resourceGroupName, ruleName, statusName, apiVersion, this.client.acceptLanguage(), this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = listByNameDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse listByNameDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/implementation/MonitorManagementClientImpl.java b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/implementation/MonitorManagementClientImpl.java index 7a27435e62d..f41e2cda0ee 100644 --- a/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/implementation/MonitorManagementClientImpl.java +++ b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/implementation/MonitorManagementClientImpl.java @@ -315,6 +315,32 @@ public MetricBaselinesInner metricBaselines() { return this.metricBaselines; } + /** + * The MetricAlertsInner object to access its operations. + */ + private MetricAlertsInner metricAlerts; + + /** + * Gets the MetricAlertsInner object to access its operations. + * @return the MetricAlertsInner object. + */ + public MetricAlertsInner metricAlerts() { + return this.metricAlerts; + } + + /** + * The MetricAlertsStatusInner object to access its operations. + */ + private MetricAlertsStatusInner metricAlertsStatus; + + /** + * Gets the MetricAlertsStatusInner object to access its operations. + * @return the MetricAlertsStatusInner object. + */ + public MetricAlertsStatusInner metricAlertsStatus() { + return this.metricAlertsStatus; + } + /** * Initializes an instance of MonitorManagementClient client. * @@ -364,6 +390,8 @@ protected void initialize() { this.metricDefinitions = new MetricDefinitionsInner(restClient().retrofit(), this); this.metrics = new MetricsInner(restClient().retrofit(), this); this.metricBaselines = new MetricBaselinesInner(restClient().retrofit(), this); + this.metricAlerts = new MetricAlertsInner(restClient().retrofit(), this); + this.metricAlertsStatus = new MetricAlertsStatusInner(restClient().retrofit(), this); this.azureClient = new AzureClient(this); } diff --git a/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/package-info.java b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/package-info.java index 869b80781e2..fdcbdcf7339 100644 --- a/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/package-info.java +++ b/azure-mgmt-monitor/src/main/java/com/microsoft/azure/management/monitor/package-info.java @@ -5,7 +5,7 @@ // Code generated by Microsoft (R) AutoRest Code Generator. /** - * This package contains the classes for managing Azure Monitor and getting logs and metrics. + * This package contains the classes for MonitorManagementClient. * Monitor Management Client. */ package com.microsoft.azure.management.monitor;