diff --git a/profiles/preview/preview/monitor/mgmt/insights/models.go b/profiles/preview/preview/monitor/mgmt/insights/models.go index 723d85a01a30..67246a174605 100644 --- a/profiles/preview/preview/monitor/mgmt/insights/models.go +++ b/profiles/preview/preview/monitor/mgmt/insights/models.go @@ -331,19 +331,21 @@ type ItsmReceiver = original.ItsmReceiver type LocalizableString = original.LocalizableString type LocationThresholdRuleCondition = original.LocationThresholdRuleCondition type LogicAppReceiver = original.LogicAppReceiver +type LogMetricTrigger = original.LogMetricTrigger type LogProfileCollection = original.LogProfileCollection type LogProfileProperties = original.LogProfileProperties type LogProfileResource = original.LogProfileResource type LogProfileResourcePatch = original.LogProfileResourcePatch type LogSearchRule = original.LogSearchRule +type LogSearchRulePatch = original.LogSearchRulePatch type LogSearchRuleResource = original.LogSearchRuleResource type LogSearchRuleResourceCollection = original.LogSearchRuleResourceCollection +type LogSearchRuleResourcePatch = original.LogSearchRuleResourcePatch type LogSettings = original.LogSettings type ManagementEventAggregationCondition = original.ManagementEventAggregationCondition type ManagementEventRuleCondition = original.ManagementEventRuleCondition type MetadataValue = original.MetadataValue type Metric = original.Metric -type MetricAlertAction = original.MetricAlertAction type BasicMetricAlertCriteria = original.BasicMetricAlertCriteria type MetricAlertCriteria = original.MetricAlertCriteria type MetricAlertProperties = original.MetricAlertProperties 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 629b8af12d2e..1c63fb4ca8d0 100644 --- a/services/preview/monitor/mgmt/2018-03-01/insights/models.go +++ b/services/preview/monitor/mgmt/2018-03-01/insights/models.go @@ -509,14 +509,17 @@ func PossibleUnitValues() []Unit { return []Unit{UnitBytes, UnitByteSeconds, UnitBytesPerSecond, UnitCount, UnitCountPerSecond, UnitMilliSeconds, UnitPercent, UnitSeconds, UnitUnspecified} } -// BasicAction ... +// BasicAction an alert action. type BasicAction interface { AsAlertingAction() (*AlertingAction, bool) AsAction() (*Action, bool) } -// Action ... +// Action an alert action. type Action struct { + // ActionGroupID - the id of the action group to use. + ActionGroupID *string `json:"actionGroupId,omitempty"` + WebhookProperties map[string]*string `json:"webhookProperties"` // OdataType - Possible values include: 'OdataTypeAction', 'OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction' OdataType OdataTypeBasicAction `json:"odata.type,omitempty"` } @@ -562,6 +565,12 @@ func unmarshalBasicActionArray(body []byte) ([]BasicAction, error) { func (a Action) MarshalJSON() ([]byte, error) { a.OdataType = OdataTypeAction objectMap := make(map[string]interface{}) + if a.ActionGroupID != nil { + objectMap["actionGroupId"] = a.ActionGroupID + } + if a.WebhookProperties != nil { + objectMap["webhookProperties"] = a.WebhookProperties + } if a.OdataType != "" { objectMap["odata.type"] = a.OdataType } @@ -1031,6 +1040,9 @@ type AlertingAction struct { ThrottlingInMin *int32 `json:"throttlingInMin,omitempty"` // Trigger - The trigger condition that results in the alert rule being. Trigger *TriggerCondition `json:"trigger,omitempty"` + // ActionGroupID - the id of the action group to use. + ActionGroupID *string `json:"actionGroupId,omitempty"` + WebhookProperties map[string]*string `json:"webhookProperties"` // OdataType - Possible values include: 'OdataTypeAction', 'OdataTypeMicrosoftWindowsAzureManagementMonitoringAlertsModelsMicrosoftAppInsightsNexusDataContractsResourcesScheduledQueryRulesAlertingAction' OdataType OdataTypeBasicAction `json:"odata.type,omitempty"` } @@ -1051,6 +1063,12 @@ func (aa AlertingAction) MarshalJSON() ([]byte, error) { if aa.Trigger != nil { objectMap["trigger"] = aa.Trigger } + if aa.ActionGroupID != nil { + objectMap["actionGroupId"] = aa.ActionGroupID + } + if aa.WebhookProperties != nil { + objectMap["webhookProperties"] = aa.WebhookProperties + } if aa.OdataType != "" { objectMap["odata.type"] = aa.OdataType } @@ -2443,6 +2461,17 @@ type LogicAppReceiver struct { CallbackURL *string `json:"callbackUrl,omitempty"` } +// LogMetricTrigger ... +type LogMetricTrigger struct { + // ThresholdOperator - Evaluation operation for Metric -'GreaterThan' or 'LessThan' or 'Equal'. Possible values include: 'ConditionalOperatorGreaterThan', 'ConditionalOperatorLessThan', 'ConditionalOperatorEqual' + ThresholdOperator ConditionalOperator `json:"thresholdOperator,omitempty"` + Threshold *float64 `json:"threshold,omitempty"` + // MetricTriggerType - Metric Trigger Type - 'Consecutive' or 'Total'. Possible values include: 'MetricTriggerTypeConsecutive', 'MetricTriggerTypeTotal' + MetricTriggerType MetricTriggerType `json:"metricTriggerType,omitempty"` + // MetricColumn - Evaluation of metric on a particular column + MetricColumn *string `json:"metricColumn,omitempty"` +} + // LogProfileCollection represents a collection of log profiles. type LogProfileCollection struct { autorest.Response `json:"-"` @@ -2722,6 +2751,12 @@ func (lsr *LogSearchRule) UnmarshalJSON(body []byte) error { return nil } +// LogSearchRulePatch log Search Rule Definition for Patching +type LogSearchRulePatch struct { + // Enabled - The flag which indicates whether the Log Search rule is enabled. Value should be true or false. Possible values include: 'True', 'False' + Enabled Enabled `json:"enabled,omitempty"` +} + // LogSearchRuleResource the Log Search Rule resource. type LogSearchRuleResource struct { autorest.Response `json:"-"` @@ -2839,6 +2874,59 @@ type LogSearchRuleResourceCollection struct { Value *[]LogSearchRuleResource `json:"value,omitempty"` } +// LogSearchRuleResourcePatch the log search rule resource for patch operations. +type LogSearchRuleResourcePatch struct { + // Tags - Resource tags + Tags map[string]*string `json:"tags"` + // LogSearchRulePatch - The log search rule properties of the resource. + *LogSearchRulePatch `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for LogSearchRuleResourcePatch. +func (lsrrp LogSearchRuleResourcePatch) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if lsrrp.Tags != nil { + objectMap["tags"] = lsrrp.Tags + } + if lsrrp.LogSearchRulePatch != nil { + objectMap["properties"] = lsrrp.LogSearchRulePatch + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for LogSearchRuleResourcePatch struct. +func (lsrrp *LogSearchRuleResourcePatch) 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 "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + lsrrp.Tags = tags + } + case "properties": + if v != nil { + var logSearchRulePatch LogSearchRulePatch + err = json.Unmarshal(*v, &logSearchRulePatch) + if err != nil { + return err + } + lsrrp.LogSearchRulePatch = &logSearchRulePatch + } + } + } + + return nil +} + // LogSettings part of MultiTenantDiagnosticSettings. Specifies the settings for a particular log. type LogSettings struct { // Category - Name of a Diagnostic Log category for a resource type this setting is applied to. To obtain the list of Diagnostic Log categories for a resource, first perform a GET diagnostic settings operation. @@ -2971,25 +3059,6 @@ type Metric struct { Timeseries *[]TimeSeriesElement `json:"timeseries,omitempty"` } -// MetricAlertAction an alert action. -type MetricAlertAction struct { - // ActionGroupID - the id of the action group to use. - ActionGroupID *string `json:"actionGroupId,omitempty"` - WebhookProperties map[string]*string `json:"webhookProperties"` -} - -// MarshalJSON is the custom marshaler for MetricAlertAction. -func (maa MetricAlertAction) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if maa.ActionGroupID != nil { - objectMap["actionGroupId"] = maa.ActionGroupID - } - if maa.WebhookProperties != nil { - objectMap["webhookProperties"] = maa.WebhookProperties - } - return json.Marshal(objectMap) -} - // BasicMetricAlertCriteria the rule criteria that defines the conditions of the alert rule. type BasicMetricAlertCriteria interface { AsMetricAlertSingleResourceMultipleMetricCriteria() (*MetricAlertSingleResourceMultipleMetricCriteria, bool) @@ -3088,7 +3157,7 @@ type MetricAlertProperties struct { // AutoMitigate - the flag that indicates whether the alert should be auto resolved or not. AutoMitigate *bool `json:"autoMitigate,omitempty"` // Actions - the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved. - Actions *[]MetricAlertAction `json:"actions,omitempty"` + Actions *[]BasicAction `json:"actions,omitempty"` // LastUpdatedTime - Last time the rule was updated in ISO8601 format. LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"` } @@ -3175,8 +3244,7 @@ func (mapVar *MetricAlertProperties) UnmarshalJSON(body []byte) error { } case "actions": if v != nil { - var actions []MetricAlertAction - err = json.Unmarshal(*v, &actions) + actions, err := unmarshalBasicActionArray(*v) if err != nil { return err } @@ -3550,12 +3618,6 @@ type MetricTrigger struct { Operator ComparisonOperationType `json:"operator,omitempty"` // Threshold - the threshold of the metric that triggers the scale action. Threshold *float64 `json:"threshold,omitempty"` - // ThresholdOperator - Evaluation operation for Metric -'GreaterThan' or 'LessThan' or 'Equal'. Possible values include: 'ConditionalOperatorGreaterThan', 'ConditionalOperatorLessThan', 'ConditionalOperatorEqual' - ThresholdOperator ConditionalOperator `json:"thresholdOperator,omitempty"` - // MetricTriggerType - Metric Trigger Type - 'Consecutive' or 'Total'. Possible values include: 'MetricTriggerTypeConsecutive', 'MetricTriggerTypeTotal' - MetricTriggerType MetricTriggerType `json:"metricTriggerType,omitempty"` - // MetricColumn - Evaluation of metric on a particular column - MetricColumn *string `json:"metricColumn,omitempty"` } // MetricValue represents a metric value. @@ -4300,7 +4362,7 @@ type Source struct { AuthorizedResources *[]string `json:"authorizedResources,omitempty"` // DataSourceID - The resource uri over which log search query is to be run. DataSourceID *string `json:"dataSourceId,omitempty"` - // QueryType - Set value to ResultCount if query should be returning search result count. Set it to Number if its a metric query. Possible values include: 'ResultCount' + // QueryType - Set value to 'ResultCount'. Possible values include: 'ResultCount' QueryType QueryType `json:"queryType,omitempty"` } @@ -4471,7 +4533,7 @@ type TriggerCondition struct { // Threshold - Result or count threshold based on which rule should be triggered. Threshold *float64 `json:"threshold,omitempty"` // MetricTrigger - Trigger condition for metric query rule - MetricTrigger *MetricTrigger `json:"metricTrigger,omitempty"` + MetricTrigger *LogMetricTrigger `json:"metricTrigger,omitempty"` } // VoiceReceiver a voice receiver. diff --git a/services/preview/monitor/mgmt/2018-03-01/insights/scheduledqueryrules.go b/services/preview/monitor/mgmt/2018-03-01/insights/scheduledqueryrules.go index 99d77ba3bbeb..d8cc76492783 100644 --- a/services/preview/monitor/mgmt/2018-03-01/insights/scheduledqueryrules.go +++ b/services/preview/monitor/mgmt/2018-03-01/insights/scheduledqueryrules.go @@ -396,3 +396,73 @@ func (client ScheduledQueryRulesClient) ListBySubscriptionResponder(resp *http.R result.Response = autorest.Response{Response: resp} return } + +// Update update log search Rule. +// Parameters: +// resourceGroupName - the name of the resource group. +// ruleName - the name of the rule. +// parameters - the parameters of the rule to update. +func (client ScheduledQueryRulesClient) Update(ctx context.Context, resourceGroupName string, ruleName string, parameters LogSearchRuleResourcePatch) (result LogSearchRuleResource, err error) { + req, err := client.UpdatePreparer(ctx, resourceGroupName, ruleName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "insights.ScheduledQueryRulesClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client ScheduledQueryRulesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, ruleName string, parameters LogSearchRuleResourcePatch) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleName": autorest.Encode("path", ruleName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-04-16" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/microsoft.insights/scheduledQueryRules/{ruleName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client ScheduledQueryRulesClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client ScheduledQueryRulesClient) UpdateResponder(resp *http.Response) (result LogSearchRuleResource, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +}