diff --git a/profiles/2019-03-01/resources/mgmt/insights/models.go b/profiles/2019-03-01/resources/mgmt/insights/models.go index b4cc0b6de0f0..9d288e9ecdd6 100644 --- a/profiles/2019-03-01/resources/mgmt/insights/models.go +++ b/profiles/2019-03-01/resources/mgmt/insights/models.go @@ -88,8 +88,9 @@ const ( type CriterionType = original.CriterionType const ( - CriterionTypeMultiMetricCriteria CriterionType = original.CriterionTypeMultiMetricCriteria - CriterionTypeStaticThresholdCriterion CriterionType = original.CriterionTypeStaticThresholdCriterion + CriterionTypeDynamicThresholdCriterion CriterionType = original.CriterionTypeDynamicThresholdCriterion + CriterionTypeMultiMetricCriteria CriterionType = original.CriterionTypeMultiMetricCriteria + CriterionTypeStaticThresholdCriterion CriterionType = original.CriterionTypeStaticThresholdCriterion ) type Enabled = original.Enabled @@ -328,6 +329,8 @@ type DiagnosticSettingsClient = original.DiagnosticSettingsClient type DiagnosticSettingsResource = original.DiagnosticSettingsResource type DiagnosticSettingsResourceCollection = original.DiagnosticSettingsResourceCollection type Dimension = original.Dimension +type DynamicMetricCriteria = original.DynamicMetricCriteria +type DynamicThresholdFailingPeriods = original.DynamicThresholdFailingPeriods type EmailNotification = original.EmailNotification type EmailReceiver = original.EmailReceiver type EnableRequest = original.EnableRequest diff --git a/profiles/preview/preview/monitor/mgmt/insights/models.go b/profiles/preview/preview/monitor/mgmt/insights/models.go index 106b7bc7fe5d..bf1acd57314a 100644 --- a/profiles/preview/preview/monitor/mgmt/insights/models.go +++ b/profiles/preview/preview/monitor/mgmt/insights/models.go @@ -96,8 +96,9 @@ const ( type CriterionType = original.CriterionType const ( - CriterionTypeMultiMetricCriteria CriterionType = original.CriterionTypeMultiMetricCriteria - CriterionTypeStaticThresholdCriterion CriterionType = original.CriterionTypeStaticThresholdCriterion + CriterionTypeDynamicThresholdCriterion CriterionType = original.CriterionTypeDynamicThresholdCriterion + CriterionTypeMultiMetricCriteria CriterionType = original.CriterionTypeMultiMetricCriteria + CriterionTypeStaticThresholdCriterion CriterionType = original.CriterionTypeStaticThresholdCriterion ) type DataStatus = original.DataStatus @@ -355,6 +356,8 @@ type DiagnosticSettingsClient = original.DiagnosticSettingsClient type DiagnosticSettingsResource = original.DiagnosticSettingsResource type DiagnosticSettingsResourceCollection = original.DiagnosticSettingsResourceCollection type Dimension = original.Dimension +type DynamicMetricCriteria = original.DynamicMetricCriteria +type DynamicThresholdFailingPeriods = original.DynamicThresholdFailingPeriods type EmailNotification = original.EmailNotification type EmailReceiver = original.EmailReceiver type EnableRequest = original.EnableRequest diff --git a/services/preview/monitor/mgmt/2018-03-01/insights/models.go b/services/preview/monitor/mgmt/2018-03-01/insights/models.go index 74fc1197457a..d8a54921c48b 100644 --- a/services/preview/monitor/mgmt/2018-03-01/insights/models.go +++ b/services/preview/monitor/mgmt/2018-03-01/insights/models.go @@ -152,6 +152,8 @@ func PossibleConditionOperatorValues() []ConditionOperator { type CriterionType string const ( + // CriterionTypeDynamicThresholdCriterion ... + CriterionTypeDynamicThresholdCriterion CriterionType = "DynamicThresholdCriterion" // CriterionTypeMultiMetricCriteria ... CriterionTypeMultiMetricCriteria CriterionType = "MultiMetricCriteria" // CriterionTypeStaticThresholdCriterion ... @@ -160,7 +162,7 @@ const ( // PossibleCriterionTypeValues returns an array of possible values for the CriterionType const type. func PossibleCriterionTypeValues() []CriterionType { - return []CriterionType{CriterionTypeMultiMetricCriteria, CriterionTypeStaticThresholdCriterion} + return []CriterionType{CriterionTypeDynamicThresholdCriterion, CriterionTypeMultiMetricCriteria, CriterionTypeStaticThresholdCriterion} } // Enabled enumerates the values for enabled. @@ -2046,6 +2048,218 @@ type Dimension struct { Values *[]string `json:"values,omitempty"` } +// DynamicMetricCriteria criterion for dynamic threshold. +type DynamicMetricCriteria struct { + // Operator - The operator used to compare the metric value against the threshold. + Operator interface{} `json:"operator,omitempty"` + // AlertSensitivity - The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. + AlertSensitivity interface{} `json:"alertSensitivity,omitempty"` + // FailingPeriods - The minimum number of violations required within the selected lookback time window required to raise an alert. + FailingPeriods *DynamicThresholdFailingPeriods `json:"failingPeriods,omitempty"` + // IgnoreDataBefore - Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format) + IgnoreDataBefore *date.Time `json:"ignoreDataBefore,omitempty"` + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // Name - Name of the criteria. + Name *string `json:"name,omitempty"` + // MetricName - Name of the metric. + MetricName *string `json:"metricName,omitempty"` + // MetricNamespace - Namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // TimeAggregation - the criteria time aggregation types. + TimeAggregation interface{} `json:"timeAggregation,omitempty"` + // Dimensions - List of dimension conditions. + Dimensions *[]MetricDimension `json:"dimensions,omitempty"` + // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion' + CriterionType CriterionType `json:"criterionType,omitempty"` +} + +// MarshalJSON is the custom marshaler for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) MarshalJSON() ([]byte, error) { + dmc.CriterionType = CriterionTypeDynamicThresholdCriterion + objectMap := make(map[string]interface{}) + if dmc.Operator != nil { + objectMap["operator"] = dmc.Operator + } + if dmc.AlertSensitivity != nil { + objectMap["alertSensitivity"] = dmc.AlertSensitivity + } + if dmc.FailingPeriods != nil { + objectMap["failingPeriods"] = dmc.FailingPeriods + } + if dmc.IgnoreDataBefore != nil { + objectMap["ignoreDataBefore"] = dmc.IgnoreDataBefore + } + if dmc.Name != nil { + objectMap["name"] = dmc.Name + } + if dmc.MetricName != nil { + objectMap["metricName"] = dmc.MetricName + } + if dmc.MetricNamespace != nil { + objectMap["metricNamespace"] = dmc.MetricNamespace + } + if dmc.TimeAggregation != nil { + objectMap["timeAggregation"] = dmc.TimeAggregation + } + if dmc.Dimensions != nil { + objectMap["dimensions"] = dmc.Dimensions + } + if dmc.CriterionType != "" { + objectMap["criterionType"] = dmc.CriterionType + } + for k, v := range dmc.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// AsMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsMetricCriteria() (*MetricCriteria, bool) { + return nil, false +} + +// AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) { + return &dmc, true +} + +// AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) { + return nil, false +} + +// AsBasicMultiMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsBasicMultiMetricCriteria() (BasicMultiMetricCriteria, bool) { + return &dmc, true +} + +// UnmarshalJSON is the custom unmarshaler for DynamicMetricCriteria struct. +func (dmc *DynamicMetricCriteria) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "operator": + if v != nil { + var operator interface{} + err = json.Unmarshal(*v, &operator) + if err != nil { + return err + } + dmc.Operator = operator + } + case "alertSensitivity": + if v != nil { + var alertSensitivity interface{} + err = json.Unmarshal(*v, &alertSensitivity) + if err != nil { + return err + } + dmc.AlertSensitivity = alertSensitivity + } + case "failingPeriods": + if v != nil { + var failingPeriods DynamicThresholdFailingPeriods + err = json.Unmarshal(*v, &failingPeriods) + if err != nil { + return err + } + dmc.FailingPeriods = &failingPeriods + } + case "ignoreDataBefore": + if v != nil { + var ignoreDataBefore date.Time + err = json.Unmarshal(*v, &ignoreDataBefore) + if err != nil { + return err + } + dmc.IgnoreDataBefore = &ignoreDataBefore + } + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if dmc.AdditionalProperties == nil { + dmc.AdditionalProperties = make(map[string]interface{}) + } + dmc.AdditionalProperties[k] = additionalProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dmc.Name = &name + } + case "metricName": + if v != nil { + var metricName string + err = json.Unmarshal(*v, &metricName) + if err != nil { + return err + } + dmc.MetricName = &metricName + } + case "metricNamespace": + if v != nil { + var metricNamespace string + err = json.Unmarshal(*v, &metricNamespace) + if err != nil { + return err + } + dmc.MetricNamespace = &metricNamespace + } + case "timeAggregation": + if v != nil { + var timeAggregation interface{} + err = json.Unmarshal(*v, &timeAggregation) + if err != nil { + return err + } + dmc.TimeAggregation = timeAggregation + } + case "dimensions": + if v != nil { + var dimensions []MetricDimension + err = json.Unmarshal(*v, &dimensions) + if err != nil { + return err + } + dmc.Dimensions = &dimensions + } + case "criterionType": + if v != nil { + var criterionType CriterionType + err = json.Unmarshal(*v, &criterionType) + if err != nil { + return err + } + dmc.CriterionType = criterionType + } + } + } + + return nil +} + +// DynamicThresholdFailingPeriods the minimum number of violations required within the selected lookback +// time window required to raise an alert. +type DynamicThresholdFailingPeriods struct { + // NumberOfEvaluationPeriods - The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points. + NumberOfEvaluationPeriods *float64 `json:"numberOfEvaluationPeriods,omitempty"` + // MinFailingPeriodsToAlert - The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. + MinFailingPeriodsToAlert *float64 `json:"minFailingPeriodsToAlert,omitempty"` +} + // EmailNotification email notification of an autoscale event. type EmailNotification struct { // SendToSubscriptionAdministrator - a value indicating whether to send email to subscription administrator. @@ -3778,23 +3992,23 @@ type MetricAvailability struct { // MetricCriteria criterion to filter metrics. type MetricCriteria struct { + // Operator - the criteria operator. + Operator interface{} `json:"operator,omitempty"` + // Threshold - the criteria threshold value that activates the alert. + Threshold *float64 `json:"threshold,omitempty"` + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` // Name - Name of the criteria. Name *string `json:"name,omitempty"` // MetricName - Name of the metric. MetricName *string `json:"metricName,omitempty"` // MetricNamespace - Namespace of the metric. MetricNamespace *string `json:"metricNamespace,omitempty"` - // Operator - the criteria operator. - Operator interface{} `json:"operator,omitempty"` // TimeAggregation - the criteria time aggregation types. TimeAggregation interface{} `json:"timeAggregation,omitempty"` - // Threshold - the criteria threshold value that activates the alert. - Threshold *float64 `json:"threshold,omitempty"` // Dimensions - List of dimension conditions. Dimensions *[]MetricDimension `json:"dimensions,omitempty"` - // AdditionalProperties - Unmatched properties from the message are deserialized this collection - AdditionalProperties map[string]interface{} `json:""` - // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion' + // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion' CriterionType CriterionType `json:"criterionType,omitempty"` } @@ -3802,6 +4016,12 @@ type MetricCriteria struct { func (mc MetricCriteria) MarshalJSON() ([]byte, error) { mc.CriterionType = CriterionTypeStaticThresholdCriterion objectMap := make(map[string]interface{}) + if mc.Operator != nil { + objectMap["operator"] = mc.Operator + } + if mc.Threshold != nil { + objectMap["threshold"] = mc.Threshold + } if mc.Name != nil { objectMap["name"] = mc.Name } @@ -3811,15 +4031,9 @@ func (mc MetricCriteria) MarshalJSON() ([]byte, error) { if mc.MetricNamespace != nil { objectMap["metricNamespace"] = mc.MetricNamespace } - if mc.Operator != nil { - objectMap["operator"] = mc.Operator - } if mc.TimeAggregation != nil { objectMap["timeAggregation"] = mc.TimeAggregation } - if mc.Threshold != nil { - objectMap["threshold"] = mc.Threshold - } if mc.Dimensions != nil { objectMap["dimensions"] = mc.Dimensions } @@ -3837,6 +4051,11 @@ func (mc MetricCriteria) AsMetricCriteria() (*MetricCriteria, bool) { return &mc, true } +// AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for MetricCriteria. +func (mc MetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) { + return nil, false +} + // AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for MetricCriteria. func (mc MetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) { return nil, false @@ -3856,6 +4075,36 @@ func (mc *MetricCriteria) UnmarshalJSON(body []byte) error { } for k, v := range m { switch k { + case "operator": + if v != nil { + var operator interface{} + err = json.Unmarshal(*v, &operator) + if err != nil { + return err + } + mc.Operator = operator + } + case "threshold": + if v != nil { + var threshold float64 + err = json.Unmarshal(*v, &threshold) + if err != nil { + return err + } + mc.Threshold = &threshold + } + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if mc.AdditionalProperties == nil { + mc.AdditionalProperties = make(map[string]interface{}) + } + mc.AdditionalProperties[k] = additionalProperties + } case "name": if v != nil { var name string @@ -3883,15 +4132,6 @@ func (mc *MetricCriteria) UnmarshalJSON(body []byte) error { } mc.MetricNamespace = &metricNamespace } - case "operator": - if v != nil { - var operator interface{} - err = json.Unmarshal(*v, &operator) - if err != nil { - return err - } - mc.Operator = operator - } case "timeAggregation": if v != nil { var timeAggregation interface{} @@ -3901,15 +4141,6 @@ func (mc *MetricCriteria) UnmarshalJSON(body []byte) error { } mc.TimeAggregation = timeAggregation } - case "threshold": - if v != nil { - var threshold float64 - err = json.Unmarshal(*v, &threshold) - if err != nil { - return err - } - mc.Threshold = &threshold - } case "dimensions": if v != nil { var dimensions []MetricDimension @@ -3919,18 +4150,6 @@ func (mc *MetricCriteria) UnmarshalJSON(body []byte) error { } mc.Dimensions = &dimensions } - default: - if v != nil { - var additionalProperties interface{} - err = json.Unmarshal(*v, &additionalProperties) - if err != nil { - return err - } - if mc.AdditionalProperties == nil { - mc.AdditionalProperties = make(map[string]interface{}) - } - mc.AdditionalProperties[k] = additionalProperties - } case "criterionType": if v != nil { var criterionType CriterionType @@ -4035,17 +4254,28 @@ type MetricValue struct { Count *int64 `json:"count,omitempty"` } -// BasicMultiMetricCriteria the types of conditions for a multi resource alert +// BasicMultiMetricCriteria the types of conditions for a multi resource alert. type BasicMultiMetricCriteria interface { AsMetricCriteria() (*MetricCriteria, bool) + AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) } -// MultiMetricCriteria the types of conditions for a multi resource alert +// MultiMetricCriteria the types of conditions for a multi resource alert. type MultiMetricCriteria struct { // AdditionalProperties - Unmatched properties from the message are deserialized this collection AdditionalProperties map[string]interface{} `json:""` - // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion' + // Name - Name of the criteria. + Name *string `json:"name,omitempty"` + // MetricName - Name of the metric. + MetricName *string `json:"metricName,omitempty"` + // MetricNamespace - Namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // TimeAggregation - the criteria time aggregation types. + TimeAggregation interface{} `json:"timeAggregation,omitempty"` + // Dimensions - List of dimension conditions. + Dimensions *[]MetricDimension `json:"dimensions,omitempty"` + // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion' CriterionType CriterionType `json:"criterionType,omitempty"` } @@ -4061,6 +4291,10 @@ func unmarshalBasicMultiMetricCriteria(body []byte) (BasicMultiMetricCriteria, e var mc MetricCriteria err := json.Unmarshal(body, &mc) return mc, err + case string(CriterionTypeDynamicThresholdCriterion): + var dmc DynamicMetricCriteria + err := json.Unmarshal(body, &dmc) + return dmc, err default: var mmc MultiMetricCriteria err := json.Unmarshal(body, &mmc) @@ -4090,6 +4324,21 @@ func unmarshalBasicMultiMetricCriteriaArray(body []byte) ([]BasicMultiMetricCrit func (mmc MultiMetricCriteria) MarshalJSON() ([]byte, error) { mmc.CriterionType = CriterionTypeMultiMetricCriteria objectMap := make(map[string]interface{}) + if mmc.Name != nil { + objectMap["name"] = mmc.Name + } + if mmc.MetricName != nil { + objectMap["metricName"] = mmc.MetricName + } + if mmc.MetricNamespace != nil { + objectMap["metricNamespace"] = mmc.MetricNamespace + } + if mmc.TimeAggregation != nil { + objectMap["timeAggregation"] = mmc.TimeAggregation + } + if mmc.Dimensions != nil { + objectMap["dimensions"] = mmc.Dimensions + } if mmc.CriterionType != "" { objectMap["criterionType"] = mmc.CriterionType } @@ -4104,6 +4353,11 @@ func (mmc MultiMetricCriteria) AsMetricCriteria() (*MetricCriteria, bool) { return nil, false } +// AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria. +func (mmc MultiMetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) { + return nil, false +} + // AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria. func (mmc MultiMetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) { return &mmc, true @@ -4135,6 +4389,51 @@ func (mmc *MultiMetricCriteria) UnmarshalJSON(body []byte) error { } mmc.AdditionalProperties[k] = additionalProperties } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mmc.Name = &name + } + case "metricName": + if v != nil { + var metricName string + err = json.Unmarshal(*v, &metricName) + if err != nil { + return err + } + mmc.MetricName = &metricName + } + case "metricNamespace": + if v != nil { + var metricNamespace string + err = json.Unmarshal(*v, &metricNamespace) + if err != nil { + return err + } + mmc.MetricNamespace = &metricNamespace + } + case "timeAggregation": + if v != nil { + var timeAggregation interface{} + err = json.Unmarshal(*v, &timeAggregation) + if err != nil { + return err + } + mmc.TimeAggregation = timeAggregation + } + case "dimensions": + if v != nil { + var dimensions []MetricDimension + err = json.Unmarshal(*v, &dimensions) + if err != nil { + return err + } + mmc.Dimensions = &dimensions + } case "criterionType": if v != nil { var criterionType CriterionType diff --git a/services/preview/monitor/mgmt/2018-09-01/insights/models.go b/services/preview/monitor/mgmt/2018-09-01/insights/models.go index 58387ad0a062..9589abedaa71 100644 --- a/services/preview/monitor/mgmt/2018-09-01/insights/models.go +++ b/services/preview/monitor/mgmt/2018-09-01/insights/models.go @@ -152,6 +152,8 @@ func PossibleConditionOperatorValues() []ConditionOperator { type CriterionType string const ( + // CriterionTypeDynamicThresholdCriterion ... + CriterionTypeDynamicThresholdCriterion CriterionType = "DynamicThresholdCriterion" // CriterionTypeMultiMetricCriteria ... CriterionTypeMultiMetricCriteria CriterionType = "MultiMetricCriteria" // CriterionTypeStaticThresholdCriterion ... @@ -160,7 +162,7 @@ const ( // PossibleCriterionTypeValues returns an array of possible values for the CriterionType const type. func PossibleCriterionTypeValues() []CriterionType { - return []CriterionType{CriterionTypeMultiMetricCriteria, CriterionTypeStaticThresholdCriterion} + return []CriterionType{CriterionTypeDynamicThresholdCriterion, CriterionTypeMultiMetricCriteria, CriterionTypeStaticThresholdCriterion} } // Enabled enumerates the values for enabled. @@ -2056,6 +2058,218 @@ type Dimension struct { Values *[]string `json:"values,omitempty"` } +// DynamicMetricCriteria criterion for dynamic threshold. +type DynamicMetricCriteria struct { + // Operator - The operator used to compare the metric value against the threshold. + Operator interface{} `json:"operator,omitempty"` + // AlertSensitivity - The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. + AlertSensitivity interface{} `json:"alertSensitivity,omitempty"` + // FailingPeriods - The minimum number of violations required within the selected lookback time window required to raise an alert. + FailingPeriods *DynamicThresholdFailingPeriods `json:"failingPeriods,omitempty"` + // IgnoreDataBefore - Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format) + IgnoreDataBefore *date.Time `json:"ignoreDataBefore,omitempty"` + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // Name - Name of the criteria. + Name *string `json:"name,omitempty"` + // MetricName - Name of the metric. + MetricName *string `json:"metricName,omitempty"` + // MetricNamespace - Namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // TimeAggregation - the criteria time aggregation types. + TimeAggregation interface{} `json:"timeAggregation,omitempty"` + // Dimensions - List of dimension conditions. + Dimensions *[]MetricDimension `json:"dimensions,omitempty"` + // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion' + CriterionType CriterionType `json:"criterionType,omitempty"` +} + +// MarshalJSON is the custom marshaler for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) MarshalJSON() ([]byte, error) { + dmc.CriterionType = CriterionTypeDynamicThresholdCriterion + objectMap := make(map[string]interface{}) + if dmc.Operator != nil { + objectMap["operator"] = dmc.Operator + } + if dmc.AlertSensitivity != nil { + objectMap["alertSensitivity"] = dmc.AlertSensitivity + } + if dmc.FailingPeriods != nil { + objectMap["failingPeriods"] = dmc.FailingPeriods + } + if dmc.IgnoreDataBefore != nil { + objectMap["ignoreDataBefore"] = dmc.IgnoreDataBefore + } + if dmc.Name != nil { + objectMap["name"] = dmc.Name + } + if dmc.MetricName != nil { + objectMap["metricName"] = dmc.MetricName + } + if dmc.MetricNamespace != nil { + objectMap["metricNamespace"] = dmc.MetricNamespace + } + if dmc.TimeAggregation != nil { + objectMap["timeAggregation"] = dmc.TimeAggregation + } + if dmc.Dimensions != nil { + objectMap["dimensions"] = dmc.Dimensions + } + if dmc.CriterionType != "" { + objectMap["criterionType"] = dmc.CriterionType + } + for k, v := range dmc.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// AsMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsMetricCriteria() (*MetricCriteria, bool) { + return nil, false +} + +// AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) { + return &dmc, true +} + +// AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) { + return nil, false +} + +// AsBasicMultiMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsBasicMultiMetricCriteria() (BasicMultiMetricCriteria, bool) { + return &dmc, true +} + +// UnmarshalJSON is the custom unmarshaler for DynamicMetricCriteria struct. +func (dmc *DynamicMetricCriteria) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "operator": + if v != nil { + var operator interface{} + err = json.Unmarshal(*v, &operator) + if err != nil { + return err + } + dmc.Operator = operator + } + case "alertSensitivity": + if v != nil { + var alertSensitivity interface{} + err = json.Unmarshal(*v, &alertSensitivity) + if err != nil { + return err + } + dmc.AlertSensitivity = alertSensitivity + } + case "failingPeriods": + if v != nil { + var failingPeriods DynamicThresholdFailingPeriods + err = json.Unmarshal(*v, &failingPeriods) + if err != nil { + return err + } + dmc.FailingPeriods = &failingPeriods + } + case "ignoreDataBefore": + if v != nil { + var ignoreDataBefore date.Time + err = json.Unmarshal(*v, &ignoreDataBefore) + if err != nil { + return err + } + dmc.IgnoreDataBefore = &ignoreDataBefore + } + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if dmc.AdditionalProperties == nil { + dmc.AdditionalProperties = make(map[string]interface{}) + } + dmc.AdditionalProperties[k] = additionalProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dmc.Name = &name + } + case "metricName": + if v != nil { + var metricName string + err = json.Unmarshal(*v, &metricName) + if err != nil { + return err + } + dmc.MetricName = &metricName + } + case "metricNamespace": + if v != nil { + var metricNamespace string + err = json.Unmarshal(*v, &metricNamespace) + if err != nil { + return err + } + dmc.MetricNamespace = &metricNamespace + } + case "timeAggregation": + if v != nil { + var timeAggregation interface{} + err = json.Unmarshal(*v, &timeAggregation) + if err != nil { + return err + } + dmc.TimeAggregation = timeAggregation + } + case "dimensions": + if v != nil { + var dimensions []MetricDimension + err = json.Unmarshal(*v, &dimensions) + if err != nil { + return err + } + dmc.Dimensions = &dimensions + } + case "criterionType": + if v != nil { + var criterionType CriterionType + err = json.Unmarshal(*v, &criterionType) + if err != nil { + return err + } + dmc.CriterionType = criterionType + } + } + } + + return nil +} + +// DynamicThresholdFailingPeriods the minimum number of violations required within the selected lookback +// time window required to raise an alert. +type DynamicThresholdFailingPeriods struct { + // NumberOfEvaluationPeriods - The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points. + NumberOfEvaluationPeriods *float64 `json:"numberOfEvaluationPeriods,omitempty"` + // MinFailingPeriodsToAlert - The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. + MinFailingPeriodsToAlert *float64 `json:"minFailingPeriodsToAlert,omitempty"` +} + // EmailNotification email notification of an autoscale event. type EmailNotification struct { // SendToSubscriptionAdministrator - a value indicating whether to send email to subscription administrator. @@ -3788,23 +4002,23 @@ type MetricAvailability struct { // MetricCriteria criterion to filter metrics. type MetricCriteria struct { + // Operator - the criteria operator. + Operator interface{} `json:"operator,omitempty"` + // Threshold - the criteria threshold value that activates the alert. + Threshold *float64 `json:"threshold,omitempty"` + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` // Name - Name of the criteria. Name *string `json:"name,omitempty"` // MetricName - Name of the metric. MetricName *string `json:"metricName,omitempty"` // MetricNamespace - Namespace of the metric. MetricNamespace *string `json:"metricNamespace,omitempty"` - // Operator - the criteria operator. - Operator interface{} `json:"operator,omitempty"` // TimeAggregation - the criteria time aggregation types. TimeAggregation interface{} `json:"timeAggregation,omitempty"` - // Threshold - the criteria threshold value that activates the alert. - Threshold *float64 `json:"threshold,omitempty"` // Dimensions - List of dimension conditions. Dimensions *[]MetricDimension `json:"dimensions,omitempty"` - // AdditionalProperties - Unmatched properties from the message are deserialized this collection - AdditionalProperties map[string]interface{} `json:""` - // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion' + // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion' CriterionType CriterionType `json:"criterionType,omitempty"` } @@ -3812,6 +4026,12 @@ type MetricCriteria struct { func (mc MetricCriteria) MarshalJSON() ([]byte, error) { mc.CriterionType = CriterionTypeStaticThresholdCriterion objectMap := make(map[string]interface{}) + if mc.Operator != nil { + objectMap["operator"] = mc.Operator + } + if mc.Threshold != nil { + objectMap["threshold"] = mc.Threshold + } if mc.Name != nil { objectMap["name"] = mc.Name } @@ -3821,15 +4041,9 @@ func (mc MetricCriteria) MarshalJSON() ([]byte, error) { if mc.MetricNamespace != nil { objectMap["metricNamespace"] = mc.MetricNamespace } - if mc.Operator != nil { - objectMap["operator"] = mc.Operator - } if mc.TimeAggregation != nil { objectMap["timeAggregation"] = mc.TimeAggregation } - if mc.Threshold != nil { - objectMap["threshold"] = mc.Threshold - } if mc.Dimensions != nil { objectMap["dimensions"] = mc.Dimensions } @@ -3847,6 +4061,11 @@ func (mc MetricCriteria) AsMetricCriteria() (*MetricCriteria, bool) { return &mc, true } +// AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for MetricCriteria. +func (mc MetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) { + return nil, false +} + // AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for MetricCriteria. func (mc MetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) { return nil, false @@ -3866,6 +4085,36 @@ func (mc *MetricCriteria) UnmarshalJSON(body []byte) error { } for k, v := range m { switch k { + case "operator": + if v != nil { + var operator interface{} + err = json.Unmarshal(*v, &operator) + if err != nil { + return err + } + mc.Operator = operator + } + case "threshold": + if v != nil { + var threshold float64 + err = json.Unmarshal(*v, &threshold) + if err != nil { + return err + } + mc.Threshold = &threshold + } + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if mc.AdditionalProperties == nil { + mc.AdditionalProperties = make(map[string]interface{}) + } + mc.AdditionalProperties[k] = additionalProperties + } case "name": if v != nil { var name string @@ -3893,15 +4142,6 @@ func (mc *MetricCriteria) UnmarshalJSON(body []byte) error { } mc.MetricNamespace = &metricNamespace } - case "operator": - if v != nil { - var operator interface{} - err = json.Unmarshal(*v, &operator) - if err != nil { - return err - } - mc.Operator = operator - } case "timeAggregation": if v != nil { var timeAggregation interface{} @@ -3911,15 +4151,6 @@ func (mc *MetricCriteria) UnmarshalJSON(body []byte) error { } mc.TimeAggregation = timeAggregation } - case "threshold": - if v != nil { - var threshold float64 - err = json.Unmarshal(*v, &threshold) - if err != nil { - return err - } - mc.Threshold = &threshold - } case "dimensions": if v != nil { var dimensions []MetricDimension @@ -3929,18 +4160,6 @@ func (mc *MetricCriteria) UnmarshalJSON(body []byte) error { } mc.Dimensions = &dimensions } - default: - if v != nil { - var additionalProperties interface{} - err = json.Unmarshal(*v, &additionalProperties) - if err != nil { - return err - } - if mc.AdditionalProperties == nil { - mc.AdditionalProperties = make(map[string]interface{}) - } - mc.AdditionalProperties[k] = additionalProperties - } case "criterionType": if v != nil { var criterionType CriterionType @@ -4070,17 +4289,28 @@ type MetricValue struct { Count *int64 `json:"count,omitempty"` } -// BasicMultiMetricCriteria the types of conditions for a multi resource alert +// BasicMultiMetricCriteria the types of conditions for a multi resource alert. type BasicMultiMetricCriteria interface { AsMetricCriteria() (*MetricCriteria, bool) + AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) } -// MultiMetricCriteria the types of conditions for a multi resource alert +// MultiMetricCriteria the types of conditions for a multi resource alert. type MultiMetricCriteria struct { // AdditionalProperties - Unmatched properties from the message are deserialized this collection AdditionalProperties map[string]interface{} `json:""` - // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion' + // Name - Name of the criteria. + Name *string `json:"name,omitempty"` + // MetricName - Name of the metric. + MetricName *string `json:"metricName,omitempty"` + // MetricNamespace - Namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // TimeAggregation - the criteria time aggregation types. + TimeAggregation interface{} `json:"timeAggregation,omitempty"` + // Dimensions - List of dimension conditions. + Dimensions *[]MetricDimension `json:"dimensions,omitempty"` + // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion' CriterionType CriterionType `json:"criterionType,omitempty"` } @@ -4096,6 +4326,10 @@ func unmarshalBasicMultiMetricCriteria(body []byte) (BasicMultiMetricCriteria, e var mc MetricCriteria err := json.Unmarshal(body, &mc) return mc, err + case string(CriterionTypeDynamicThresholdCriterion): + var dmc DynamicMetricCriteria + err := json.Unmarshal(body, &dmc) + return dmc, err default: var mmc MultiMetricCriteria err := json.Unmarshal(body, &mmc) @@ -4125,6 +4359,21 @@ func unmarshalBasicMultiMetricCriteriaArray(body []byte) ([]BasicMultiMetricCrit func (mmc MultiMetricCriteria) MarshalJSON() ([]byte, error) { mmc.CriterionType = CriterionTypeMultiMetricCriteria objectMap := make(map[string]interface{}) + if mmc.Name != nil { + objectMap["name"] = mmc.Name + } + if mmc.MetricName != nil { + objectMap["metricName"] = mmc.MetricName + } + if mmc.MetricNamespace != nil { + objectMap["metricNamespace"] = mmc.MetricNamespace + } + if mmc.TimeAggregation != nil { + objectMap["timeAggregation"] = mmc.TimeAggregation + } + if mmc.Dimensions != nil { + objectMap["dimensions"] = mmc.Dimensions + } if mmc.CriterionType != "" { objectMap["criterionType"] = mmc.CriterionType } @@ -4139,6 +4388,11 @@ func (mmc MultiMetricCriteria) AsMetricCriteria() (*MetricCriteria, bool) { return nil, false } +// AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria. +func (mmc MultiMetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) { + return nil, false +} + // AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria. func (mmc MultiMetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) { return &mmc, true @@ -4170,6 +4424,51 @@ func (mmc *MultiMetricCriteria) UnmarshalJSON(body []byte) error { } mmc.AdditionalProperties[k] = additionalProperties } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mmc.Name = &name + } + case "metricName": + if v != nil { + var metricName string + err = json.Unmarshal(*v, &metricName) + if err != nil { + return err + } + mmc.MetricName = &metricName + } + case "metricNamespace": + if v != nil { + var metricNamespace string + err = json.Unmarshal(*v, &metricNamespace) + if err != nil { + return err + } + mmc.MetricNamespace = &metricNamespace + } + case "timeAggregation": + if v != nil { + var timeAggregation interface{} + err = json.Unmarshal(*v, &timeAggregation) + if err != nil { + return err + } + mmc.TimeAggregation = timeAggregation + } + case "dimensions": + if v != nil { + var dimensions []MetricDimension + err = json.Unmarshal(*v, &dimensions) + if err != nil { + return err + } + mmc.Dimensions = &dimensions + } case "criterionType": if v != nil { var criterionType CriterionType diff --git a/services/preview/monitor/mgmt/2018-11-01-preview/insights/models.go b/services/preview/monitor/mgmt/2018-11-01-preview/insights/models.go index 4777212e18a7..181f6edb5d98 100644 --- a/services/preview/monitor/mgmt/2018-11-01-preview/insights/models.go +++ b/services/preview/monitor/mgmt/2018-11-01-preview/insights/models.go @@ -152,6 +152,8 @@ func PossibleConditionOperatorValues() []ConditionOperator { type CriterionType string const ( + // CriterionTypeDynamicThresholdCriterion ... + CriterionTypeDynamicThresholdCriterion CriterionType = "DynamicThresholdCriterion" // CriterionTypeMultiMetricCriteria ... CriterionTypeMultiMetricCriteria CriterionType = "MultiMetricCriteria" // CriterionTypeStaticThresholdCriterion ... @@ -160,7 +162,7 @@ const ( // PossibleCriterionTypeValues returns an array of possible values for the CriterionType const type. func PossibleCriterionTypeValues() []CriterionType { - return []CriterionType{CriterionTypeMultiMetricCriteria, CriterionTypeStaticThresholdCriterion} + return []CriterionType{CriterionTypeDynamicThresholdCriterion, CriterionTypeMultiMetricCriteria, CriterionTypeStaticThresholdCriterion} } // DataStatus enumerates the values for data status. @@ -2094,6 +2096,218 @@ type Dimension struct { Values *[]string `json:"values,omitempty"` } +// DynamicMetricCriteria criterion for dynamic threshold. +type DynamicMetricCriteria struct { + // Operator - The operator used to compare the metric value against the threshold. + Operator interface{} `json:"operator,omitempty"` + // AlertSensitivity - The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. + AlertSensitivity interface{} `json:"alertSensitivity,omitempty"` + // FailingPeriods - The minimum number of violations required within the selected lookback time window required to raise an alert. + FailingPeriods *DynamicThresholdFailingPeriods `json:"failingPeriods,omitempty"` + // IgnoreDataBefore - Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format) + IgnoreDataBefore *date.Time `json:"ignoreDataBefore,omitempty"` + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // Name - Name of the criteria. + Name *string `json:"name,omitempty"` + // MetricName - Name of the metric. + MetricName *string `json:"metricName,omitempty"` + // MetricNamespace - Namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // TimeAggregation - the criteria time aggregation types. + TimeAggregation interface{} `json:"timeAggregation,omitempty"` + // Dimensions - List of dimension conditions. + Dimensions *[]MetricDimension `json:"dimensions,omitempty"` + // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion' + CriterionType CriterionType `json:"criterionType,omitempty"` +} + +// MarshalJSON is the custom marshaler for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) MarshalJSON() ([]byte, error) { + dmc.CriterionType = CriterionTypeDynamicThresholdCriterion + objectMap := make(map[string]interface{}) + if dmc.Operator != nil { + objectMap["operator"] = dmc.Operator + } + if dmc.AlertSensitivity != nil { + objectMap["alertSensitivity"] = dmc.AlertSensitivity + } + if dmc.FailingPeriods != nil { + objectMap["failingPeriods"] = dmc.FailingPeriods + } + if dmc.IgnoreDataBefore != nil { + objectMap["ignoreDataBefore"] = dmc.IgnoreDataBefore + } + if dmc.Name != nil { + objectMap["name"] = dmc.Name + } + if dmc.MetricName != nil { + objectMap["metricName"] = dmc.MetricName + } + if dmc.MetricNamespace != nil { + objectMap["metricNamespace"] = dmc.MetricNamespace + } + if dmc.TimeAggregation != nil { + objectMap["timeAggregation"] = dmc.TimeAggregation + } + if dmc.Dimensions != nil { + objectMap["dimensions"] = dmc.Dimensions + } + if dmc.CriterionType != "" { + objectMap["criterionType"] = dmc.CriterionType + } + for k, v := range dmc.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// AsMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsMetricCriteria() (*MetricCriteria, bool) { + return nil, false +} + +// AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) { + return &dmc, true +} + +// AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) { + return nil, false +} + +// AsBasicMultiMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsBasicMultiMetricCriteria() (BasicMultiMetricCriteria, bool) { + return &dmc, true +} + +// UnmarshalJSON is the custom unmarshaler for DynamicMetricCriteria struct. +func (dmc *DynamicMetricCriteria) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "operator": + if v != nil { + var operator interface{} + err = json.Unmarshal(*v, &operator) + if err != nil { + return err + } + dmc.Operator = operator + } + case "alertSensitivity": + if v != nil { + var alertSensitivity interface{} + err = json.Unmarshal(*v, &alertSensitivity) + if err != nil { + return err + } + dmc.AlertSensitivity = alertSensitivity + } + case "failingPeriods": + if v != nil { + var failingPeriods DynamicThresholdFailingPeriods + err = json.Unmarshal(*v, &failingPeriods) + if err != nil { + return err + } + dmc.FailingPeriods = &failingPeriods + } + case "ignoreDataBefore": + if v != nil { + var ignoreDataBefore date.Time + err = json.Unmarshal(*v, &ignoreDataBefore) + if err != nil { + return err + } + dmc.IgnoreDataBefore = &ignoreDataBefore + } + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if dmc.AdditionalProperties == nil { + dmc.AdditionalProperties = make(map[string]interface{}) + } + dmc.AdditionalProperties[k] = additionalProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dmc.Name = &name + } + case "metricName": + if v != nil { + var metricName string + err = json.Unmarshal(*v, &metricName) + if err != nil { + return err + } + dmc.MetricName = &metricName + } + case "metricNamespace": + if v != nil { + var metricNamespace string + err = json.Unmarshal(*v, &metricNamespace) + if err != nil { + return err + } + dmc.MetricNamespace = &metricNamespace + } + case "timeAggregation": + if v != nil { + var timeAggregation interface{} + err = json.Unmarshal(*v, &timeAggregation) + if err != nil { + return err + } + dmc.TimeAggregation = timeAggregation + } + case "dimensions": + if v != nil { + var dimensions []MetricDimension + err = json.Unmarshal(*v, &dimensions) + if err != nil { + return err + } + dmc.Dimensions = &dimensions + } + case "criterionType": + if v != nil { + var criterionType CriterionType + err = json.Unmarshal(*v, &criterionType) + if err != nil { + return err + } + dmc.CriterionType = criterionType + } + } + } + + return nil +} + +// DynamicThresholdFailingPeriods the minimum number of violations required within the selected lookback +// time window required to raise an alert. +type DynamicThresholdFailingPeriods struct { + // NumberOfEvaluationPeriods - The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points. + NumberOfEvaluationPeriods *float64 `json:"numberOfEvaluationPeriods,omitempty"` + // MinFailingPeriodsToAlert - The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. + MinFailingPeriodsToAlert *float64 `json:"minFailingPeriodsToAlert,omitempty"` +} + // EmailNotification email notification of an autoscale event. type EmailNotification struct { // SendToSubscriptionAdministrator - a value indicating whether to send email to subscription administrator. @@ -3834,23 +4048,23 @@ type MetricAvailability struct { // MetricCriteria criterion to filter metrics. type MetricCriteria struct { + // Operator - the criteria operator. + Operator interface{} `json:"operator,omitempty"` + // Threshold - the criteria threshold value that activates the alert. + Threshold *float64 `json:"threshold,omitempty"` + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` // Name - Name of the criteria. Name *string `json:"name,omitempty"` // MetricName - Name of the metric. MetricName *string `json:"metricName,omitempty"` // MetricNamespace - Namespace of the metric. MetricNamespace *string `json:"metricNamespace,omitempty"` - // Operator - the criteria operator. - Operator interface{} `json:"operator,omitempty"` // TimeAggregation - the criteria time aggregation types. TimeAggregation interface{} `json:"timeAggregation,omitempty"` - // Threshold - the criteria threshold value that activates the alert. - Threshold *float64 `json:"threshold,omitempty"` // Dimensions - List of dimension conditions. Dimensions *[]MetricDimension `json:"dimensions,omitempty"` - // AdditionalProperties - Unmatched properties from the message are deserialized this collection - AdditionalProperties map[string]interface{} `json:""` - // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion' + // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion' CriterionType CriterionType `json:"criterionType,omitempty"` } @@ -3858,6 +4072,12 @@ type MetricCriteria struct { func (mc MetricCriteria) MarshalJSON() ([]byte, error) { mc.CriterionType = CriterionTypeStaticThresholdCriterion objectMap := make(map[string]interface{}) + if mc.Operator != nil { + objectMap["operator"] = mc.Operator + } + if mc.Threshold != nil { + objectMap["threshold"] = mc.Threshold + } if mc.Name != nil { objectMap["name"] = mc.Name } @@ -3867,15 +4087,9 @@ func (mc MetricCriteria) MarshalJSON() ([]byte, error) { if mc.MetricNamespace != nil { objectMap["metricNamespace"] = mc.MetricNamespace } - if mc.Operator != nil { - objectMap["operator"] = mc.Operator - } if mc.TimeAggregation != nil { objectMap["timeAggregation"] = mc.TimeAggregation } - if mc.Threshold != nil { - objectMap["threshold"] = mc.Threshold - } if mc.Dimensions != nil { objectMap["dimensions"] = mc.Dimensions } @@ -3893,6 +4107,11 @@ func (mc MetricCriteria) AsMetricCriteria() (*MetricCriteria, bool) { return &mc, true } +// AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for MetricCriteria. +func (mc MetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) { + return nil, false +} + // AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for MetricCriteria. func (mc MetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) { return nil, false @@ -3912,6 +4131,36 @@ func (mc *MetricCriteria) UnmarshalJSON(body []byte) error { } for k, v := range m { switch k { + case "operator": + if v != nil { + var operator interface{} + err = json.Unmarshal(*v, &operator) + if err != nil { + return err + } + mc.Operator = operator + } + case "threshold": + if v != nil { + var threshold float64 + err = json.Unmarshal(*v, &threshold) + if err != nil { + return err + } + mc.Threshold = &threshold + } + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if mc.AdditionalProperties == nil { + mc.AdditionalProperties = make(map[string]interface{}) + } + mc.AdditionalProperties[k] = additionalProperties + } case "name": if v != nil { var name string @@ -3939,15 +4188,6 @@ func (mc *MetricCriteria) UnmarshalJSON(body []byte) error { } mc.MetricNamespace = &metricNamespace } - case "operator": - if v != nil { - var operator interface{} - err = json.Unmarshal(*v, &operator) - if err != nil { - return err - } - mc.Operator = operator - } case "timeAggregation": if v != nil { var timeAggregation interface{} @@ -3957,15 +4197,6 @@ func (mc *MetricCriteria) UnmarshalJSON(body []byte) error { } mc.TimeAggregation = timeAggregation } - case "threshold": - if v != nil { - var threshold float64 - err = json.Unmarshal(*v, &threshold) - if err != nil { - return err - } - mc.Threshold = &threshold - } case "dimensions": if v != nil { var dimensions []MetricDimension @@ -3975,18 +4206,6 @@ func (mc *MetricCriteria) UnmarshalJSON(body []byte) error { } mc.Dimensions = &dimensions } - default: - if v != nil { - var additionalProperties interface{} - err = json.Unmarshal(*v, &additionalProperties) - if err != nil { - return err - } - if mc.AdditionalProperties == nil { - mc.AdditionalProperties = make(map[string]interface{}) - } - mc.AdditionalProperties[k] = additionalProperties - } case "criterionType": if v != nil { var criterionType CriterionType @@ -4116,17 +4335,28 @@ type MetricValue struct { Count *int64 `json:"count,omitempty"` } -// BasicMultiMetricCriteria the types of conditions for a multi resource alert +// BasicMultiMetricCriteria the types of conditions for a multi resource alert. type BasicMultiMetricCriteria interface { AsMetricCriteria() (*MetricCriteria, bool) + AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) } -// MultiMetricCriteria the types of conditions for a multi resource alert +// MultiMetricCriteria the types of conditions for a multi resource alert. type MultiMetricCriteria struct { // AdditionalProperties - Unmatched properties from the message are deserialized this collection AdditionalProperties map[string]interface{} `json:""` - // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion' + // Name - Name of the criteria. + Name *string `json:"name,omitempty"` + // MetricName - Name of the metric. + MetricName *string `json:"metricName,omitempty"` + // MetricNamespace - Namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // TimeAggregation - the criteria time aggregation types. + TimeAggregation interface{} `json:"timeAggregation,omitempty"` + // Dimensions - List of dimension conditions. + Dimensions *[]MetricDimension `json:"dimensions,omitempty"` + // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion' CriterionType CriterionType `json:"criterionType,omitempty"` } @@ -4142,6 +4372,10 @@ func unmarshalBasicMultiMetricCriteria(body []byte) (BasicMultiMetricCriteria, e var mc MetricCriteria err := json.Unmarshal(body, &mc) return mc, err + case string(CriterionTypeDynamicThresholdCriterion): + var dmc DynamicMetricCriteria + err := json.Unmarshal(body, &dmc) + return dmc, err default: var mmc MultiMetricCriteria err := json.Unmarshal(body, &mmc) @@ -4171,6 +4405,21 @@ func unmarshalBasicMultiMetricCriteriaArray(body []byte) ([]BasicMultiMetricCrit func (mmc MultiMetricCriteria) MarshalJSON() ([]byte, error) { mmc.CriterionType = CriterionTypeMultiMetricCriteria objectMap := make(map[string]interface{}) + if mmc.Name != nil { + objectMap["name"] = mmc.Name + } + if mmc.MetricName != nil { + objectMap["metricName"] = mmc.MetricName + } + if mmc.MetricNamespace != nil { + objectMap["metricNamespace"] = mmc.MetricNamespace + } + if mmc.TimeAggregation != nil { + objectMap["timeAggregation"] = mmc.TimeAggregation + } + if mmc.Dimensions != nil { + objectMap["dimensions"] = mmc.Dimensions + } if mmc.CriterionType != "" { objectMap["criterionType"] = mmc.CriterionType } @@ -4185,6 +4434,11 @@ func (mmc MultiMetricCriteria) AsMetricCriteria() (*MetricCriteria, bool) { return nil, false } +// AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria. +func (mmc MultiMetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) { + return nil, false +} + // AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria. func (mmc MultiMetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) { return &mmc, true @@ -4216,6 +4470,51 @@ func (mmc *MultiMetricCriteria) UnmarshalJSON(body []byte) error { } mmc.AdditionalProperties[k] = additionalProperties } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mmc.Name = &name + } + case "metricName": + if v != nil { + var metricName string + err = json.Unmarshal(*v, &metricName) + if err != nil { + return err + } + mmc.MetricName = &metricName + } + case "metricNamespace": + if v != nil { + var metricNamespace string + err = json.Unmarshal(*v, &metricNamespace) + if err != nil { + return err + } + mmc.MetricNamespace = &metricNamespace + } + case "timeAggregation": + if v != nil { + var timeAggregation interface{} + err = json.Unmarshal(*v, &timeAggregation) + if err != nil { + return err + } + mmc.TimeAggregation = timeAggregation + } + case "dimensions": + if v != nil { + var dimensions []MetricDimension + err = json.Unmarshal(*v, &dimensions) + if err != nil { + return err + } + mmc.Dimensions = &dimensions + } case "criterionType": if v != nil { var criterionType CriterionType diff --git a/services/preview/monitor/mgmt/2019-03-01/insights/models.go b/services/preview/monitor/mgmt/2019-03-01/insights/models.go index 7fdf9742a42e..273563db83c0 100644 --- a/services/preview/monitor/mgmt/2019-03-01/insights/models.go +++ b/services/preview/monitor/mgmt/2019-03-01/insights/models.go @@ -169,6 +169,8 @@ func PossibleConditionOperatorValues() []ConditionOperator { type CriterionType string const ( + // CriterionTypeDynamicThresholdCriterion ... + CriterionTypeDynamicThresholdCriterion CriterionType = "DynamicThresholdCriterion" // CriterionTypeMultiMetricCriteria ... CriterionTypeMultiMetricCriteria CriterionType = "MultiMetricCriteria" // CriterionTypeStaticThresholdCriterion ... @@ -177,7 +179,7 @@ const ( // PossibleCriterionTypeValues returns an array of possible values for the CriterionType const type. func PossibleCriterionTypeValues() []CriterionType { - return []CriterionType{CriterionTypeMultiMetricCriteria, CriterionTypeStaticThresholdCriterion} + return []CriterionType{CriterionTypeDynamicThresholdCriterion, CriterionTypeMultiMetricCriteria, CriterionTypeStaticThresholdCriterion} } // DataStatus enumerates the values for data status. @@ -2125,6 +2127,218 @@ type Dimension struct { Values *[]string `json:"values,omitempty"` } +// DynamicMetricCriteria criterion for dynamic threshold. +type DynamicMetricCriteria struct { + // Operator - The operator used to compare the metric value against the threshold. + Operator interface{} `json:"operator,omitempty"` + // AlertSensitivity - The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. + AlertSensitivity interface{} `json:"alertSensitivity,omitempty"` + // FailingPeriods - The minimum number of violations required within the selected lookback time window required to raise an alert. + FailingPeriods *DynamicThresholdFailingPeriods `json:"failingPeriods,omitempty"` + // IgnoreDataBefore - Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format) + IgnoreDataBefore *date.Time `json:"ignoreDataBefore,omitempty"` + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` + // Name - Name of the criteria. + Name *string `json:"name,omitempty"` + // MetricName - Name of the metric. + MetricName *string `json:"metricName,omitempty"` + // MetricNamespace - Namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // TimeAggregation - the criteria time aggregation types. + TimeAggregation interface{} `json:"timeAggregation,omitempty"` + // Dimensions - List of dimension conditions. + Dimensions *[]MetricDimension `json:"dimensions,omitempty"` + // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion' + CriterionType CriterionType `json:"criterionType,omitempty"` +} + +// MarshalJSON is the custom marshaler for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) MarshalJSON() ([]byte, error) { + dmc.CriterionType = CriterionTypeDynamicThresholdCriterion + objectMap := make(map[string]interface{}) + if dmc.Operator != nil { + objectMap["operator"] = dmc.Operator + } + if dmc.AlertSensitivity != nil { + objectMap["alertSensitivity"] = dmc.AlertSensitivity + } + if dmc.FailingPeriods != nil { + objectMap["failingPeriods"] = dmc.FailingPeriods + } + if dmc.IgnoreDataBefore != nil { + objectMap["ignoreDataBefore"] = dmc.IgnoreDataBefore + } + if dmc.Name != nil { + objectMap["name"] = dmc.Name + } + if dmc.MetricName != nil { + objectMap["metricName"] = dmc.MetricName + } + if dmc.MetricNamespace != nil { + objectMap["metricNamespace"] = dmc.MetricNamespace + } + if dmc.TimeAggregation != nil { + objectMap["timeAggregation"] = dmc.TimeAggregation + } + if dmc.Dimensions != nil { + objectMap["dimensions"] = dmc.Dimensions + } + if dmc.CriterionType != "" { + objectMap["criterionType"] = dmc.CriterionType + } + for k, v := range dmc.AdditionalProperties { + objectMap[k] = v + } + return json.Marshal(objectMap) +} + +// AsMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsMetricCriteria() (*MetricCriteria, bool) { + return nil, false +} + +// AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) { + return &dmc, true +} + +// AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) { + return nil, false +} + +// AsBasicMultiMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria. +func (dmc DynamicMetricCriteria) AsBasicMultiMetricCriteria() (BasicMultiMetricCriteria, bool) { + return &dmc, true +} + +// UnmarshalJSON is the custom unmarshaler for DynamicMetricCriteria struct. +func (dmc *DynamicMetricCriteria) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "operator": + if v != nil { + var operator interface{} + err = json.Unmarshal(*v, &operator) + if err != nil { + return err + } + dmc.Operator = operator + } + case "alertSensitivity": + if v != nil { + var alertSensitivity interface{} + err = json.Unmarshal(*v, &alertSensitivity) + if err != nil { + return err + } + dmc.AlertSensitivity = alertSensitivity + } + case "failingPeriods": + if v != nil { + var failingPeriods DynamicThresholdFailingPeriods + err = json.Unmarshal(*v, &failingPeriods) + if err != nil { + return err + } + dmc.FailingPeriods = &failingPeriods + } + case "ignoreDataBefore": + if v != nil { + var ignoreDataBefore date.Time + err = json.Unmarshal(*v, &ignoreDataBefore) + if err != nil { + return err + } + dmc.IgnoreDataBefore = &ignoreDataBefore + } + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if dmc.AdditionalProperties == nil { + dmc.AdditionalProperties = make(map[string]interface{}) + } + dmc.AdditionalProperties[k] = additionalProperties + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + dmc.Name = &name + } + case "metricName": + if v != nil { + var metricName string + err = json.Unmarshal(*v, &metricName) + if err != nil { + return err + } + dmc.MetricName = &metricName + } + case "metricNamespace": + if v != nil { + var metricNamespace string + err = json.Unmarshal(*v, &metricNamespace) + if err != nil { + return err + } + dmc.MetricNamespace = &metricNamespace + } + case "timeAggregation": + if v != nil { + var timeAggregation interface{} + err = json.Unmarshal(*v, &timeAggregation) + if err != nil { + return err + } + dmc.TimeAggregation = timeAggregation + } + case "dimensions": + if v != nil { + var dimensions []MetricDimension + err = json.Unmarshal(*v, &dimensions) + if err != nil { + return err + } + dmc.Dimensions = &dimensions + } + case "criterionType": + if v != nil { + var criterionType CriterionType + err = json.Unmarshal(*v, &criterionType) + if err != nil { + return err + } + dmc.CriterionType = criterionType + } + } + } + + return nil +} + +// DynamicThresholdFailingPeriods the minimum number of violations required within the selected lookback +// time window required to raise an alert. +type DynamicThresholdFailingPeriods struct { + // NumberOfEvaluationPeriods - The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points. + NumberOfEvaluationPeriods *float64 `json:"numberOfEvaluationPeriods,omitempty"` + // MinFailingPeriodsToAlert - The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods. + MinFailingPeriodsToAlert *float64 `json:"minFailingPeriodsToAlert,omitempty"` +} + // EmailNotification email notification of an autoscale event. type EmailNotification struct { // SendToSubscriptionAdministrator - a value indicating whether to send email to subscription administrator. @@ -3888,23 +4102,23 @@ type MetricBaselinesResponse struct { // MetricCriteria criterion to filter metrics. type MetricCriteria struct { + // Operator - the criteria operator. + Operator interface{} `json:"operator,omitempty"` + // Threshold - the criteria threshold value that activates the alert. + Threshold *float64 `json:"threshold,omitempty"` + // AdditionalProperties - Unmatched properties from the message are deserialized this collection + AdditionalProperties map[string]interface{} `json:""` // Name - Name of the criteria. Name *string `json:"name,omitempty"` // MetricName - Name of the metric. MetricName *string `json:"metricName,omitempty"` // MetricNamespace - Namespace of the metric. MetricNamespace *string `json:"metricNamespace,omitempty"` - // Operator - the criteria operator. - Operator interface{} `json:"operator,omitempty"` // TimeAggregation - the criteria time aggregation types. TimeAggregation interface{} `json:"timeAggregation,omitempty"` - // Threshold - the criteria threshold value that activates the alert. - Threshold *float64 `json:"threshold,omitempty"` // Dimensions - List of dimension conditions. Dimensions *[]MetricDimension `json:"dimensions,omitempty"` - // AdditionalProperties - Unmatched properties from the message are deserialized this collection - AdditionalProperties map[string]interface{} `json:""` - // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion' + // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion' CriterionType CriterionType `json:"criterionType,omitempty"` } @@ -3912,6 +4126,12 @@ type MetricCriteria struct { func (mc MetricCriteria) MarshalJSON() ([]byte, error) { mc.CriterionType = CriterionTypeStaticThresholdCriterion objectMap := make(map[string]interface{}) + if mc.Operator != nil { + objectMap["operator"] = mc.Operator + } + if mc.Threshold != nil { + objectMap["threshold"] = mc.Threshold + } if mc.Name != nil { objectMap["name"] = mc.Name } @@ -3921,15 +4141,9 @@ func (mc MetricCriteria) MarshalJSON() ([]byte, error) { if mc.MetricNamespace != nil { objectMap["metricNamespace"] = mc.MetricNamespace } - if mc.Operator != nil { - objectMap["operator"] = mc.Operator - } if mc.TimeAggregation != nil { objectMap["timeAggregation"] = mc.TimeAggregation } - if mc.Threshold != nil { - objectMap["threshold"] = mc.Threshold - } if mc.Dimensions != nil { objectMap["dimensions"] = mc.Dimensions } @@ -3947,6 +4161,11 @@ func (mc MetricCriteria) AsMetricCriteria() (*MetricCriteria, bool) { return &mc, true } +// AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for MetricCriteria. +func (mc MetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) { + return nil, false +} + // AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for MetricCriteria. func (mc MetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) { return nil, false @@ -3966,6 +4185,36 @@ func (mc *MetricCriteria) UnmarshalJSON(body []byte) error { } for k, v := range m { switch k { + case "operator": + if v != nil { + var operator interface{} + err = json.Unmarshal(*v, &operator) + if err != nil { + return err + } + mc.Operator = operator + } + case "threshold": + if v != nil { + var threshold float64 + err = json.Unmarshal(*v, &threshold) + if err != nil { + return err + } + mc.Threshold = &threshold + } + default: + if v != nil { + var additionalProperties interface{} + err = json.Unmarshal(*v, &additionalProperties) + if err != nil { + return err + } + if mc.AdditionalProperties == nil { + mc.AdditionalProperties = make(map[string]interface{}) + } + mc.AdditionalProperties[k] = additionalProperties + } case "name": if v != nil { var name string @@ -3993,15 +4242,6 @@ func (mc *MetricCriteria) UnmarshalJSON(body []byte) error { } mc.MetricNamespace = &metricNamespace } - case "operator": - if v != nil { - var operator interface{} - err = json.Unmarshal(*v, &operator) - if err != nil { - return err - } - mc.Operator = operator - } case "timeAggregation": if v != nil { var timeAggregation interface{} @@ -4011,15 +4251,6 @@ func (mc *MetricCriteria) UnmarshalJSON(body []byte) error { } mc.TimeAggregation = timeAggregation } - case "threshold": - if v != nil { - var threshold float64 - err = json.Unmarshal(*v, &threshold) - if err != nil { - return err - } - mc.Threshold = &threshold - } case "dimensions": if v != nil { var dimensions []MetricDimension @@ -4029,18 +4260,6 @@ func (mc *MetricCriteria) UnmarshalJSON(body []byte) error { } mc.Dimensions = &dimensions } - default: - if v != nil { - var additionalProperties interface{} - err = json.Unmarshal(*v, &additionalProperties) - if err != nil { - return err - } - if mc.AdditionalProperties == nil { - mc.AdditionalProperties = make(map[string]interface{}) - } - mc.AdditionalProperties[k] = additionalProperties - } case "criterionType": if v != nil { var criterionType CriterionType @@ -4178,17 +4397,28 @@ type MetricValue struct { Count *int64 `json:"count,omitempty"` } -// BasicMultiMetricCriteria the types of conditions for a multi resource alert +// BasicMultiMetricCriteria the types of conditions for a multi resource alert. type BasicMultiMetricCriteria interface { AsMetricCriteria() (*MetricCriteria, bool) + AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) } -// MultiMetricCriteria the types of conditions for a multi resource alert +// MultiMetricCriteria the types of conditions for a multi resource alert. type MultiMetricCriteria struct { // AdditionalProperties - Unmatched properties from the message are deserialized this collection AdditionalProperties map[string]interface{} `json:""` - // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion' + // Name - Name of the criteria. + Name *string `json:"name,omitempty"` + // MetricName - Name of the metric. + MetricName *string `json:"metricName,omitempty"` + // MetricNamespace - Namespace of the metric. + MetricNamespace *string `json:"metricNamespace,omitempty"` + // TimeAggregation - the criteria time aggregation types. + TimeAggregation interface{} `json:"timeAggregation,omitempty"` + // Dimensions - List of dimension conditions. + Dimensions *[]MetricDimension `json:"dimensions,omitempty"` + // CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion' CriterionType CriterionType `json:"criterionType,omitempty"` } @@ -4204,6 +4434,10 @@ func unmarshalBasicMultiMetricCriteria(body []byte) (BasicMultiMetricCriteria, e var mc MetricCriteria err := json.Unmarshal(body, &mc) return mc, err + case string(CriterionTypeDynamicThresholdCriterion): + var dmc DynamicMetricCriteria + err := json.Unmarshal(body, &dmc) + return dmc, err default: var mmc MultiMetricCriteria err := json.Unmarshal(body, &mmc) @@ -4233,6 +4467,21 @@ func unmarshalBasicMultiMetricCriteriaArray(body []byte) ([]BasicMultiMetricCrit func (mmc MultiMetricCriteria) MarshalJSON() ([]byte, error) { mmc.CriterionType = CriterionTypeMultiMetricCriteria objectMap := make(map[string]interface{}) + if mmc.Name != nil { + objectMap["name"] = mmc.Name + } + if mmc.MetricName != nil { + objectMap["metricName"] = mmc.MetricName + } + if mmc.MetricNamespace != nil { + objectMap["metricNamespace"] = mmc.MetricNamespace + } + if mmc.TimeAggregation != nil { + objectMap["timeAggregation"] = mmc.TimeAggregation + } + if mmc.Dimensions != nil { + objectMap["dimensions"] = mmc.Dimensions + } if mmc.CriterionType != "" { objectMap["criterionType"] = mmc.CriterionType } @@ -4247,6 +4496,11 @@ func (mmc MultiMetricCriteria) AsMetricCriteria() (*MetricCriteria, bool) { return nil, false } +// AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria. +func (mmc MultiMetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) { + return nil, false +} + // AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria. func (mmc MultiMetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) { return &mmc, true @@ -4278,6 +4532,51 @@ func (mmc *MultiMetricCriteria) UnmarshalJSON(body []byte) error { } mmc.AdditionalProperties[k] = additionalProperties } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + mmc.Name = &name + } + case "metricName": + if v != nil { + var metricName string + err = json.Unmarshal(*v, &metricName) + if err != nil { + return err + } + mmc.MetricName = &metricName + } + case "metricNamespace": + if v != nil { + var metricNamespace string + err = json.Unmarshal(*v, &metricNamespace) + if err != nil { + return err + } + mmc.MetricNamespace = &metricNamespace + } + case "timeAggregation": + if v != nil { + var timeAggregation interface{} + err = json.Unmarshal(*v, &timeAggregation) + if err != nil { + return err + } + mmc.TimeAggregation = timeAggregation + } + case "dimensions": + if v != nil { + var dimensions []MetricDimension + err = json.Unmarshal(*v, &dimensions) + if err != nil { + return err + } + mmc.Dimensions = &dimensions + } case "criterionType": if v != nil { var criterionType CriterionType