package alertsmanagement

// 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.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.

import (
	"context"
	"encoding/json"
	"github.com/Azure/go-autorest/autorest"
	"github.com/Azure/go-autorest/autorest/date"
	"github.com/Azure/go-autorest/autorest/to"
	"github.com/Azure/go-autorest/tracing"
	"net/http"
)

// The package's fully qualified name.
const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/alertsmanagement/mgmt/2019-06-01-preview/alertsmanagement"

// ActionGroup action rule with action group configuration
type ActionGroup struct {
	// ActionGroupID - Action group to trigger if action rule matches
	ActionGroupID *string `json:"actionGroupId,omitempty"`
	// Scope - scope on which action rule will apply
	Scope *Scope `json:"scope,omitempty"`
	// Conditions - conditions on which alerts will be filtered
	Conditions *Conditions `json:"conditions,omitempty"`
	// Description - Description of action rule
	Description *string `json:"description,omitempty"`
	// CreatedAt - READ-ONLY; Creation time of action rule. Date-Time in ISO-8601 format.
	CreatedAt *date.Time `json:"createdAt,omitempty"`
	// LastModifiedAt - READ-ONLY; Last updated time of action rule. Date-Time in ISO-8601 format.
	LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"`
	// CreatedBy - READ-ONLY; Created by user name.
	CreatedBy *string `json:"createdBy,omitempty"`
	// LastModifiedBy - READ-ONLY; Last modified by user name.
	LastModifiedBy *string `json:"lastModifiedBy,omitempty"`
	// Status - Indicates if the given action rule is enabled or disabled. Possible values include: 'Enabled', 'Disabled'
	Status ActionRuleStatus `json:"status,omitempty"`
	// Type - Possible values include: 'TypeActionRuleProperties', 'TypeSuppression', 'TypeActionGroup', 'TypeDiagnostics'
	Type Type `json:"type,omitempty"`
}

// MarshalJSON is the custom marshaler for ActionGroup.
func (ag ActionGroup) MarshalJSON() ([]byte, error) {
	ag.Type = TypeActionGroup
	objectMap := make(map[string]interface{})
	if ag.ActionGroupID != nil {
		objectMap["actionGroupId"] = ag.ActionGroupID
	}
	if ag.Scope != nil {
		objectMap["scope"] = ag.Scope
	}
	if ag.Conditions != nil {
		objectMap["conditions"] = ag.Conditions
	}
	if ag.Description != nil {
		objectMap["description"] = ag.Description
	}
	if ag.Status != "" {
		objectMap["status"] = ag.Status
	}
	if ag.Type != "" {
		objectMap["type"] = ag.Type
	}
	return json.Marshal(objectMap)
}

// AsSuppression is the BasicActionRuleProperties implementation for ActionGroup.
func (ag ActionGroup) AsSuppression() (*Suppression, bool) {
	return nil, false
}

// AsActionGroup is the BasicActionRuleProperties implementation for ActionGroup.
func (ag ActionGroup) AsActionGroup() (*ActionGroup, bool) {
	return &ag, true
}

// AsDiagnostics is the BasicActionRuleProperties implementation for ActionGroup.
func (ag ActionGroup) AsDiagnostics() (*Diagnostics, bool) {
	return nil, false
}

// AsActionRuleProperties is the BasicActionRuleProperties implementation for ActionGroup.
func (ag ActionGroup) AsActionRuleProperties() (*ActionRuleProperties, bool) {
	return nil, false
}

// AsBasicActionRuleProperties is the BasicActionRuleProperties implementation for ActionGroup.
func (ag ActionGroup) AsBasicActionRuleProperties() (BasicActionRuleProperties, bool) {
	return &ag, true
}

// ActionGroupsInformation the Action Groups information, used by the alert rule.
type ActionGroupsInformation struct {
	// CustomEmailSubject - An optional custom email subject to use in email notifications.
	CustomEmailSubject *string `json:"customEmailSubject,omitempty"`
	// CustomWebhookPayload - An optional custom web-hook payload to use in web-hook notifications.
	CustomWebhookPayload *string `json:"customWebhookPayload,omitempty"`
	// GroupIds - The Action Group resource IDs.
	GroupIds *[]string `json:"groupIds,omitempty"`
}

// ActionRule action rule object containing target scope, conditions and suppression logic
type ActionRule struct {
	autorest.Response `json:"-"`
	// Properties - action rule properties
	Properties BasicActionRuleProperties `json:"properties,omitempty"`
	// Location - Resource location
	Location *string `json:"location,omitempty"`
	// Tags - Resource tags
	Tags map[string]*string `json:"tags"`
	// ID - READ-ONLY; Azure resource Id
	ID *string `json:"id,omitempty"`
	// Type - READ-ONLY; Azure resource type
	Type *string `json:"type,omitempty"`
	// Name - READ-ONLY; Azure resource name
	Name *string `json:"name,omitempty"`
}

// MarshalJSON is the custom marshaler for ActionRule.
func (ar ActionRule) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	objectMap["properties"] = ar.Properties
	if ar.Location != nil {
		objectMap["location"] = ar.Location
	}
	if ar.Tags != nil {
		objectMap["tags"] = ar.Tags
	}
	return json.Marshal(objectMap)
}

// UnmarshalJSON is the custom unmarshaler for ActionRule struct.
func (ar *ActionRule) 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 "properties":
			if v != nil {
				properties, err := unmarshalBasicActionRuleProperties(*v)
				if err != nil {
					return err
				}
				ar.Properties = properties
			}
		case "location":
			if v != nil {
				var location string
				err = json.Unmarshal(*v, &location)
				if err != nil {
					return err
				}
				ar.Location = &location
			}
		case "tags":
			if v != nil {
				var tags map[string]*string
				err = json.Unmarshal(*v, &tags)
				if err != nil {
					return err
				}
				ar.Tags = tags
			}
		case "id":
			if v != nil {
				var ID string
				err = json.Unmarshal(*v, &ID)
				if err != nil {
					return err
				}
				ar.ID = &ID
			}
		case "type":
			if v != nil {
				var typeVar string
				err = json.Unmarshal(*v, &typeVar)
				if err != nil {
					return err
				}
				ar.Type = &typeVar
			}
		case "name":
			if v != nil {
				var name string
				err = json.Unmarshal(*v, &name)
				if err != nil {
					return err
				}
				ar.Name = &name
			}
		}
	}

	return nil
}

// BasicActionRuleProperties action rule properties defining scope, conditions, suppression logic for action rule
type BasicActionRuleProperties interface {
	AsSuppression() (*Suppression, bool)
	AsActionGroup() (*ActionGroup, bool)
	AsDiagnostics() (*Diagnostics, bool)
	AsActionRuleProperties() (*ActionRuleProperties, bool)
}

// ActionRuleProperties action rule properties defining scope, conditions, suppression logic for action rule
type ActionRuleProperties struct {
	// Scope - scope on which action rule will apply
	Scope *Scope `json:"scope,omitempty"`
	// Conditions - conditions on which alerts will be filtered
	Conditions *Conditions `json:"conditions,omitempty"`
	// Description - Description of action rule
	Description *string `json:"description,omitempty"`
	// CreatedAt - READ-ONLY; Creation time of action rule. Date-Time in ISO-8601 format.
	CreatedAt *date.Time `json:"createdAt,omitempty"`
	// LastModifiedAt - READ-ONLY; Last updated time of action rule. Date-Time in ISO-8601 format.
	LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"`
	// CreatedBy - READ-ONLY; Created by user name.
	CreatedBy *string `json:"createdBy,omitempty"`
	// LastModifiedBy - READ-ONLY; Last modified by user name.
	LastModifiedBy *string `json:"lastModifiedBy,omitempty"`
	// Status - Indicates if the given action rule is enabled or disabled. Possible values include: 'Enabled', 'Disabled'
	Status ActionRuleStatus `json:"status,omitempty"`
	// Type - Possible values include: 'TypeActionRuleProperties', 'TypeSuppression', 'TypeActionGroup', 'TypeDiagnostics'
	Type Type `json:"type,omitempty"`
}

func unmarshalBasicActionRuleProperties(body []byte) (BasicActionRuleProperties, error) {
	var m map[string]interface{}
	err := json.Unmarshal(body, &m)
	if err != nil {
		return nil, err
	}

	switch m["type"] {
	case string(TypeSuppression):
		var s Suppression
		err := json.Unmarshal(body, &s)
		return s, err
	case string(TypeActionGroup):
		var ag ActionGroup
		err := json.Unmarshal(body, &ag)
		return ag, err
	case string(TypeDiagnostics):
		var d Diagnostics
		err := json.Unmarshal(body, &d)
		return d, err
	default:
		var arp ActionRuleProperties
		err := json.Unmarshal(body, &arp)
		return arp, err
	}
}
func unmarshalBasicActionRulePropertiesArray(body []byte) ([]BasicActionRuleProperties, error) {
	var rawMessages []*json.RawMessage
	err := json.Unmarshal(body, &rawMessages)
	if err != nil {
		return nil, err
	}

	arpArray := make([]BasicActionRuleProperties, len(rawMessages))

	for index, rawMessage := range rawMessages {
		arp, err := unmarshalBasicActionRuleProperties(*rawMessage)
		if err != nil {
			return nil, err
		}
		arpArray[index] = arp
	}
	return arpArray, nil
}

// MarshalJSON is the custom marshaler for ActionRuleProperties.
func (arp ActionRuleProperties) MarshalJSON() ([]byte, error) {
	arp.Type = TypeActionRuleProperties
	objectMap := make(map[string]interface{})
	if arp.Scope != nil {
		objectMap["scope"] = arp.Scope
	}
	if arp.Conditions != nil {
		objectMap["conditions"] = arp.Conditions
	}
	if arp.Description != nil {
		objectMap["description"] = arp.Description
	}
	if arp.Status != "" {
		objectMap["status"] = arp.Status
	}
	if arp.Type != "" {
		objectMap["type"] = arp.Type
	}
	return json.Marshal(objectMap)
}

// AsSuppression is the BasicActionRuleProperties implementation for ActionRuleProperties.
func (arp ActionRuleProperties) AsSuppression() (*Suppression, bool) {
	return nil, false
}

// AsActionGroup is the BasicActionRuleProperties implementation for ActionRuleProperties.
func (arp ActionRuleProperties) AsActionGroup() (*ActionGroup, bool) {
	return nil, false
}

// AsDiagnostics is the BasicActionRuleProperties implementation for ActionRuleProperties.
func (arp ActionRuleProperties) AsDiagnostics() (*Diagnostics, bool) {
	return nil, false
}

// AsActionRuleProperties is the BasicActionRuleProperties implementation for ActionRuleProperties.
func (arp ActionRuleProperties) AsActionRuleProperties() (*ActionRuleProperties, bool) {
	return &arp, true
}

// AsBasicActionRuleProperties is the BasicActionRuleProperties implementation for ActionRuleProperties.
func (arp ActionRuleProperties) AsBasicActionRuleProperties() (BasicActionRuleProperties, bool) {
	return &arp, true
}

// ActionRulesList list of action rules
type ActionRulesList struct {
	autorest.Response `json:"-"`
	// NextLink - URL to fetch the next set of action rules
	NextLink *string `json:"nextLink,omitempty"`
	// Value - List of action rules
	Value *[]ActionRule `json:"value,omitempty"`
}

// ActionRulesListIterator provides access to a complete listing of ActionRule values.
type ActionRulesListIterator struct {
	i    int
	page ActionRulesListPage
}

// NextWithContext advances to the next value.  If there was an error making
// the request the iterator does not advance and the error is returned.
func (iter *ActionRulesListIterator) NextWithContext(ctx context.Context) (err error) {
	if tracing.IsEnabled() {
		ctx = tracing.StartSpan(ctx, fqdn+"/ActionRulesListIterator.NextWithContext")
		defer func() {
			sc := -1
			if iter.Response().Response.Response != nil {
				sc = iter.Response().Response.Response.StatusCode
			}
			tracing.EndSpan(ctx, sc, err)
		}()
	}
	iter.i++
	if iter.i < len(iter.page.Values()) {
		return nil
	}
	err = iter.page.NextWithContext(ctx)
	if err != nil {
		iter.i--
		return err
	}
	iter.i = 0
	return nil
}

// Next advances to the next value.  If there was an error making
// the request the iterator does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (iter *ActionRulesListIterator) Next() error {
	return iter.NextWithContext(context.Background())
}

// NotDone returns true if the enumeration should be started or is not yet complete.
func (iter ActionRulesListIterator) NotDone() bool {
	return iter.page.NotDone() && iter.i < len(iter.page.Values())
}

// Response returns the raw server response from the last page request.
func (iter ActionRulesListIterator) Response() ActionRulesList {
	return iter.page.Response()
}

// Value returns the current value or a zero-initialized value if the
// iterator has advanced beyond the end of the collection.
func (iter ActionRulesListIterator) Value() ActionRule {
	if !iter.page.NotDone() {
		return ActionRule{}
	}
	return iter.page.Values()[iter.i]
}

// Creates a new instance of the ActionRulesListIterator type.
func NewActionRulesListIterator(page ActionRulesListPage) ActionRulesListIterator {
	return ActionRulesListIterator{page: page}
}

// IsEmpty returns true if the ListResult contains no values.
func (arl ActionRulesList) IsEmpty() bool {
	return arl.Value == nil || len(*arl.Value) == 0
}

// hasNextLink returns true if the NextLink is not empty.
func (arl ActionRulesList) hasNextLink() bool {
	return arl.NextLink != nil && len(*arl.NextLink) != 0
}

// actionRulesListPreparer prepares a request to retrieve the next set of results.
// It returns nil if no more results exist.
func (arl ActionRulesList) actionRulesListPreparer(ctx context.Context) (*http.Request, error) {
	if !arl.hasNextLink() {
		return nil, nil
	}
	return autorest.Prepare((&http.Request{}).WithContext(ctx),
		autorest.AsJSON(),
		autorest.AsGet(),
		autorest.WithBaseURL(to.String(arl.NextLink)))
}

// ActionRulesListPage contains a page of ActionRule values.
type ActionRulesListPage struct {
	fn  func(context.Context, ActionRulesList) (ActionRulesList, error)
	arl ActionRulesList
}

// NextWithContext advances to the next page of values.  If there was an error making
// the request the page does not advance and the error is returned.
func (page *ActionRulesListPage) NextWithContext(ctx context.Context) (err error) {
	if tracing.IsEnabled() {
		ctx = tracing.StartSpan(ctx, fqdn+"/ActionRulesListPage.NextWithContext")
		defer func() {
			sc := -1
			if page.Response().Response.Response != nil {
				sc = page.Response().Response.Response.StatusCode
			}
			tracing.EndSpan(ctx, sc, err)
		}()
	}
	for {
		next, err := page.fn(ctx, page.arl)
		if err != nil {
			return err
		}
		page.arl = next
		if !next.hasNextLink() || !next.IsEmpty() {
			break
		}
	}
	return nil
}

// Next advances to the next page of values.  If there was an error making
// the request the page does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (page *ActionRulesListPage) Next() error {
	return page.NextWithContext(context.Background())
}

// NotDone returns true if the page enumeration should be started or is not yet complete.
func (page ActionRulesListPage) NotDone() bool {
	return !page.arl.IsEmpty()
}

// Response returns the raw server response from the last page request.
func (page ActionRulesListPage) Response() ActionRulesList {
	return page.arl
}

// Values returns the slice of values for the current page or nil if there are no values.
func (page ActionRulesListPage) Values() []ActionRule {
	if page.arl.IsEmpty() {
		return nil
	}
	return *page.arl.Value
}

// Creates a new instance of the ActionRulesListPage type.
func NewActionRulesListPage(cur ActionRulesList, getNextPage func(context.Context, ActionRulesList) (ActionRulesList, error)) ActionRulesListPage {
	return ActionRulesListPage{
		fn:  getNextPage,
		arl: cur,
	}
}

// Alert an alert created in alert management service.
type Alert struct {
	autorest.Response `json:"-"`
	Properties        *AlertProperties `json:"properties,omitempty"`
	// ID - READ-ONLY; Azure resource Id
	ID *string `json:"id,omitempty"`
	// Type - READ-ONLY; Azure resource type
	Type *string `json:"type,omitempty"`
	// Name - READ-ONLY; Azure resource name
	Name *string `json:"name,omitempty"`
}

// MarshalJSON is the custom marshaler for Alert.
func (a Alert) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	if a.Properties != nil {
		objectMap["properties"] = a.Properties
	}
	return json.Marshal(objectMap)
}

// AlertModification alert Modification details
type AlertModification struct {
	autorest.Response `json:"-"`
	Properties        *AlertModificationProperties `json:"properties,omitempty"`
	// ID - READ-ONLY; Azure resource Id
	ID *string `json:"id,omitempty"`
	// Type - READ-ONLY; Azure resource type
	Type *string `json:"type,omitempty"`
	// Name - READ-ONLY; Azure resource name
	Name *string `json:"name,omitempty"`
}

// MarshalJSON is the custom marshaler for AlertModification.
func (am AlertModification) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	if am.Properties != nil {
		objectMap["properties"] = am.Properties
	}
	return json.Marshal(objectMap)
}

// AlertModificationItem alert modification item.
type AlertModificationItem struct {
	// ModificationEvent - Reason for the modification. Possible values include: 'AlertCreated', 'StateChange', 'MonitorConditionChange', 'SeverityChange', 'ActionRuleTriggered', 'ActionRuleSuppressed', 'ActionsTriggered', 'ActionsSuppressed', 'ActionsFailed'
	ModificationEvent AlertModificationEvent `json:"modificationEvent,omitempty"`
	// OldValue - Old value
	OldValue *string `json:"oldValue,omitempty"`
	// NewValue - New value
	NewValue *string `json:"newValue,omitempty"`
	// ModifiedAt - Modified date and time
	ModifiedAt *string `json:"modifiedAt,omitempty"`
	// ModifiedBy - Modified user details (Principal client name)
	ModifiedBy *string `json:"modifiedBy,omitempty"`
	// Comments - Modification comments
	Comments *string `json:"comments,omitempty"`
	// Description - Description of the modification
	Description *string `json:"description,omitempty"`
}

// AlertModificationProperties properties of the alert modification item.
type AlertModificationProperties struct {
	// AlertID - READ-ONLY; Unique Id of the alert for which the history is being retrieved
	AlertID *string `json:"alertId,omitempty"`
	// Modifications - Modification details
	Modifications *[]AlertModificationItem `json:"modifications,omitempty"`
}

// MarshalJSON is the custom marshaler for AlertModificationProperties.
func (amp AlertModificationProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	if amp.Modifications != nil {
		objectMap["modifications"] = amp.Modifications
	}
	return json.Marshal(objectMap)
}

// AlertProperties alert property bag
type AlertProperties struct {
	Essentials   *Essentials `json:"essentials,omitempty"`
	Context      interface{} `json:"context,omitempty"`
	EgressConfig interface{} `json:"egressConfig,omitempty"`
}

// AlertRule the alert rule information
type AlertRule struct {
	autorest.Response `json:"-"`
	// AlertRuleProperties - The properties of the alert rule.
	*AlertRuleProperties `json:"properties,omitempty"`
	// ID - READ-ONLY; The resource ID.
	ID *string `json:"id,omitempty"`
	// Type - READ-ONLY; The resource type.
	Type *string `json:"type,omitempty"`
	// Name - READ-ONLY; The resource name.
	Name *string `json:"name,omitempty"`
	// Location - The resource location.
	Location *string `json:"location,omitempty"`
	// Tags - The resource tags.
	Tags map[string]*string `json:"tags"`
}

// MarshalJSON is the custom marshaler for AlertRule.
func (ar AlertRule) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	if ar.AlertRuleProperties != nil {
		objectMap["properties"] = ar.AlertRuleProperties
	}
	if ar.Location != nil {
		objectMap["location"] = ar.Location
	}
	if ar.Tags != nil {
		objectMap["tags"] = ar.Tags
	}
	return json.Marshal(objectMap)
}

// UnmarshalJSON is the custom unmarshaler for AlertRule struct.
func (ar *AlertRule) 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 "properties":
			if v != nil {
				var alertRuleProperties AlertRuleProperties
				err = json.Unmarshal(*v, &alertRuleProperties)
				if err != nil {
					return err
				}
				ar.AlertRuleProperties = &alertRuleProperties
			}
		case "id":
			if v != nil {
				var ID string
				err = json.Unmarshal(*v, &ID)
				if err != nil {
					return err
				}
				ar.ID = &ID
			}
		case "type":
			if v != nil {
				var typeVar string
				err = json.Unmarshal(*v, &typeVar)
				if err != nil {
					return err
				}
				ar.Type = &typeVar
			}
		case "name":
			if v != nil {
				var name string
				err = json.Unmarshal(*v, &name)
				if err != nil {
					return err
				}
				ar.Name = &name
			}
		case "location":
			if v != nil {
				var location string
				err = json.Unmarshal(*v, &location)
				if err != nil {
					return err
				}
				ar.Location = &location
			}
		case "tags":
			if v != nil {
				var tags map[string]*string
				err = json.Unmarshal(*v, &tags)
				if err != nil {
					return err
				}
				ar.Tags = tags
			}
		}
	}

	return nil
}

// AlertRulePatchObject the alert rule patch information
type AlertRulePatchObject struct {
	// ID - READ-ONLY; The resource ID.
	ID *string `json:"id,omitempty"`
	// Type - READ-ONLY; The resource type.
	Type *string `json:"type,omitempty"`
	// Name - READ-ONLY; The resource name.
	Name *string `json:"name,omitempty"`
	// Tags - The resource tags.
	Tags map[string]*string `json:"tags"`
	// AlertRulePatchProperties - The properties of the alert rule.
	*AlertRulePatchProperties `json:"properties,omitempty"`
}

// MarshalJSON is the custom marshaler for AlertRulePatchObject.
func (arpo AlertRulePatchObject) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	if arpo.Tags != nil {
		objectMap["tags"] = arpo.Tags
	}
	if arpo.AlertRulePatchProperties != nil {
		objectMap["properties"] = arpo.AlertRulePatchProperties
	}
	return json.Marshal(objectMap)
}

// UnmarshalJSON is the custom unmarshaler for AlertRulePatchObject struct.
func (arpo *AlertRulePatchObject) 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 "id":
			if v != nil {
				var ID string
				err = json.Unmarshal(*v, &ID)
				if err != nil {
					return err
				}
				arpo.ID = &ID
			}
		case "type":
			if v != nil {
				var typeVar string
				err = json.Unmarshal(*v, &typeVar)
				if err != nil {
					return err
				}
				arpo.Type = &typeVar
			}
		case "name":
			if v != nil {
				var name string
				err = json.Unmarshal(*v, &name)
				if err != nil {
					return err
				}
				arpo.Name = &name
			}
		case "tags":
			if v != nil {
				var tags map[string]*string
				err = json.Unmarshal(*v, &tags)
				if err != nil {
					return err
				}
				arpo.Tags = tags
			}
		case "properties":
			if v != nil {
				var alertRulePatchProperties AlertRulePatchProperties
				err = json.Unmarshal(*v, &alertRulePatchProperties)
				if err != nil {
					return err
				}
				arpo.AlertRulePatchProperties = &alertRulePatchProperties
			}
		}
	}

	return nil
}

// AlertRulePatchProperties the alert rule properties.
type AlertRulePatchProperties struct {
	// Description - The alert rule description.
	Description *string `json:"description,omitempty"`
	// State - The alert rule state. Possible values include: 'AlertRuleStateEnabled', 'AlertRuleStateDisabled'
	State AlertRuleState `json:"state,omitempty"`
	// Severity - The alert rule severity. Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4'
	Severity Severity `json:"severity,omitempty"`
	// Frequency - The alert rule frequency in ISO8601 format. The time granularity must be in minutes and minimum value is 5 minutes.
	Frequency *string `json:"frequency,omitempty"`
	// ActionGroups - The alert rule actions.
	ActionGroups *ActionGroupsInformation `json:"actionGroups,omitempty"`
	// Throttling - The alert rule throttling information.
	Throttling *ThrottlingInformation `json:"throttling,omitempty"`
}

// AlertRuleProperties the alert rule properties.
type AlertRuleProperties struct {
	// Description - The alert rule description.
	Description *string `json:"description,omitempty"`
	// State - The alert rule state. Possible values include: 'AlertRuleStateEnabled', 'AlertRuleStateDisabled'
	State AlertRuleState `json:"state,omitempty"`
	// Severity - The alert rule severity. Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4'
	Severity Severity `json:"severity,omitempty"`
	// Frequency - The alert rule frequency in ISO8601 format. The time granularity must be in minutes and minimum value is 5 minutes.
	Frequency *string `json:"frequency,omitempty"`
	// Detector - The alert rule's detector.
	Detector *Detector `json:"detector,omitempty"`
	// Scope - The alert rule resources scope.
	Scope *[]string `json:"scope,omitempty"`
	// ActionGroups - The alert rule actions.
	ActionGroups *ActionGroupsInformation `json:"actionGroups,omitempty"`
	// Throttling - The alert rule throttling information.
	Throttling *ThrottlingInformation `json:"throttling,omitempty"`
}

// AlertRulesList list of Smart Detector alert rules.
type AlertRulesList struct {
	autorest.Response `json:"-"`
	// Value - List of Smart Detector alert rules.
	Value *[]AlertRule `json:"value,omitempty"`
	// NextLink - The URL to get the next set of results.
	NextLink *string `json:"nextLink,omitempty"`
}

// AlertRulesListIterator provides access to a complete listing of AlertRule values.
type AlertRulesListIterator struct {
	i    int
	page AlertRulesListPage
}

// NextWithContext advances to the next value.  If there was an error making
// the request the iterator does not advance and the error is returned.
func (iter *AlertRulesListIterator) NextWithContext(ctx context.Context) (err error) {
	if tracing.IsEnabled() {
		ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesListIterator.NextWithContext")
		defer func() {
			sc := -1
			if iter.Response().Response.Response != nil {
				sc = iter.Response().Response.Response.StatusCode
			}
			tracing.EndSpan(ctx, sc, err)
		}()
	}
	iter.i++
	if iter.i < len(iter.page.Values()) {
		return nil
	}
	err = iter.page.NextWithContext(ctx)
	if err != nil {
		iter.i--
		return err
	}
	iter.i = 0
	return nil
}

// Next advances to the next value.  If there was an error making
// the request the iterator does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (iter *AlertRulesListIterator) Next() error {
	return iter.NextWithContext(context.Background())
}

// NotDone returns true if the enumeration should be started or is not yet complete.
func (iter AlertRulesListIterator) NotDone() bool {
	return iter.page.NotDone() && iter.i < len(iter.page.Values())
}

// Response returns the raw server response from the last page request.
func (iter AlertRulesListIterator) Response() AlertRulesList {
	return iter.page.Response()
}

// Value returns the current value or a zero-initialized value if the
// iterator has advanced beyond the end of the collection.
func (iter AlertRulesListIterator) Value() AlertRule {
	if !iter.page.NotDone() {
		return AlertRule{}
	}
	return iter.page.Values()[iter.i]
}

// Creates a new instance of the AlertRulesListIterator type.
func NewAlertRulesListIterator(page AlertRulesListPage) AlertRulesListIterator {
	return AlertRulesListIterator{page: page}
}

// IsEmpty returns true if the ListResult contains no values.
func (arl AlertRulesList) IsEmpty() bool {
	return arl.Value == nil || len(*arl.Value) == 0
}

// hasNextLink returns true if the NextLink is not empty.
func (arl AlertRulesList) hasNextLink() bool {
	return arl.NextLink != nil && len(*arl.NextLink) != 0
}

// alertRulesListPreparer prepares a request to retrieve the next set of results.
// It returns nil if no more results exist.
func (arl AlertRulesList) alertRulesListPreparer(ctx context.Context) (*http.Request, error) {
	if !arl.hasNextLink() {
		return nil, nil
	}
	return autorest.Prepare((&http.Request{}).WithContext(ctx),
		autorest.AsJSON(),
		autorest.AsGet(),
		autorest.WithBaseURL(to.String(arl.NextLink)))
}

// AlertRulesListPage contains a page of AlertRule values.
type AlertRulesListPage struct {
	fn  func(context.Context, AlertRulesList) (AlertRulesList, error)
	arl AlertRulesList
}

// NextWithContext advances to the next page of values.  If there was an error making
// the request the page does not advance and the error is returned.
func (page *AlertRulesListPage) NextWithContext(ctx context.Context) (err error) {
	if tracing.IsEnabled() {
		ctx = tracing.StartSpan(ctx, fqdn+"/AlertRulesListPage.NextWithContext")
		defer func() {
			sc := -1
			if page.Response().Response.Response != nil {
				sc = page.Response().Response.Response.StatusCode
			}
			tracing.EndSpan(ctx, sc, err)
		}()
	}
	for {
		next, err := page.fn(ctx, page.arl)
		if err != nil {
			return err
		}
		page.arl = next
		if !next.hasNextLink() || !next.IsEmpty() {
			break
		}
	}
	return nil
}

// Next advances to the next page of values.  If there was an error making
// the request the page does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (page *AlertRulesListPage) Next() error {
	return page.NextWithContext(context.Background())
}

// NotDone returns true if the page enumeration should be started or is not yet complete.
func (page AlertRulesListPage) NotDone() bool {
	return !page.arl.IsEmpty()
}

// Response returns the raw server response from the last page request.
func (page AlertRulesListPage) Response() AlertRulesList {
	return page.arl
}

// Values returns the slice of values for the current page or nil if there are no values.
func (page AlertRulesListPage) Values() []AlertRule {
	if page.arl.IsEmpty() {
		return nil
	}
	return *page.arl.Value
}

// Creates a new instance of the AlertRulesListPage type.
func NewAlertRulesListPage(cur AlertRulesList, getNextPage func(context.Context, AlertRulesList) (AlertRulesList, error)) AlertRulesListPage {
	return AlertRulesListPage{
		fn:  getNextPage,
		arl: cur,
	}
}

// AlertsList list the alerts.
type AlertsList struct {
	autorest.Response `json:"-"`
	// NextLink - URL to fetch the next set of alerts.
	NextLink *string `json:"nextLink,omitempty"`
	// Value - List of alerts
	Value *[]Alert `json:"value,omitempty"`
}

// AlertsListIterator provides access to a complete listing of Alert values.
type AlertsListIterator struct {
	i    int
	page AlertsListPage
}

// NextWithContext advances to the next value.  If there was an error making
// the request the iterator does not advance and the error is returned.
func (iter *AlertsListIterator) NextWithContext(ctx context.Context) (err error) {
	if tracing.IsEnabled() {
		ctx = tracing.StartSpan(ctx, fqdn+"/AlertsListIterator.NextWithContext")
		defer func() {
			sc := -1
			if iter.Response().Response.Response != nil {
				sc = iter.Response().Response.Response.StatusCode
			}
			tracing.EndSpan(ctx, sc, err)
		}()
	}
	iter.i++
	if iter.i < len(iter.page.Values()) {
		return nil
	}
	err = iter.page.NextWithContext(ctx)
	if err != nil {
		iter.i--
		return err
	}
	iter.i = 0
	return nil
}

// Next advances to the next value.  If there was an error making
// the request the iterator does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (iter *AlertsListIterator) Next() error {
	return iter.NextWithContext(context.Background())
}

// NotDone returns true if the enumeration should be started or is not yet complete.
func (iter AlertsListIterator) NotDone() bool {
	return iter.page.NotDone() && iter.i < len(iter.page.Values())
}

// Response returns the raw server response from the last page request.
func (iter AlertsListIterator) Response() AlertsList {
	return iter.page.Response()
}

// Value returns the current value or a zero-initialized value if the
// iterator has advanced beyond the end of the collection.
func (iter AlertsListIterator) Value() Alert {
	if !iter.page.NotDone() {
		return Alert{}
	}
	return iter.page.Values()[iter.i]
}

// Creates a new instance of the AlertsListIterator type.
func NewAlertsListIterator(page AlertsListPage) AlertsListIterator {
	return AlertsListIterator{page: page}
}

// IsEmpty returns true if the ListResult contains no values.
func (al AlertsList) IsEmpty() bool {
	return al.Value == nil || len(*al.Value) == 0
}

// hasNextLink returns true if the NextLink is not empty.
func (al AlertsList) hasNextLink() bool {
	return al.NextLink != nil && len(*al.NextLink) != 0
}

// alertsListPreparer prepares a request to retrieve the next set of results.
// It returns nil if no more results exist.
func (al AlertsList) alertsListPreparer(ctx context.Context) (*http.Request, error) {
	if !al.hasNextLink() {
		return nil, nil
	}
	return autorest.Prepare((&http.Request{}).WithContext(ctx),
		autorest.AsJSON(),
		autorest.AsGet(),
		autorest.WithBaseURL(to.String(al.NextLink)))
}

// AlertsListPage contains a page of Alert values.
type AlertsListPage struct {
	fn func(context.Context, AlertsList) (AlertsList, error)
	al AlertsList
}

// NextWithContext advances to the next page of values.  If there was an error making
// the request the page does not advance and the error is returned.
func (page *AlertsListPage) NextWithContext(ctx context.Context) (err error) {
	if tracing.IsEnabled() {
		ctx = tracing.StartSpan(ctx, fqdn+"/AlertsListPage.NextWithContext")
		defer func() {
			sc := -1
			if page.Response().Response.Response != nil {
				sc = page.Response().Response.Response.StatusCode
			}
			tracing.EndSpan(ctx, sc, err)
		}()
	}
	for {
		next, err := page.fn(ctx, page.al)
		if err != nil {
			return err
		}
		page.al = next
		if !next.hasNextLink() || !next.IsEmpty() {
			break
		}
	}
	return nil
}

// Next advances to the next page of values.  If there was an error making
// the request the page does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (page *AlertsListPage) Next() error {
	return page.NextWithContext(context.Background())
}

// NotDone returns true if the page enumeration should be started or is not yet complete.
func (page AlertsListPage) NotDone() bool {
	return !page.al.IsEmpty()
}

// Response returns the raw server response from the last page request.
func (page AlertsListPage) Response() AlertsList {
	return page.al
}

// Values returns the slice of values for the current page or nil if there are no values.
func (page AlertsListPage) Values() []Alert {
	if page.al.IsEmpty() {
		return nil
	}
	return *page.al.Value
}

// Creates a new instance of the AlertsListPage type.
func NewAlertsListPage(cur AlertsList, getNextPage func(context.Context, AlertsList) (AlertsList, error)) AlertsListPage {
	return AlertsListPage{
		fn: getNextPage,
		al: cur,
	}
}

// AlertsMetaData alert meta data information.
type AlertsMetaData struct {
	autorest.Response `json:"-"`
	Properties        BasicAlertsMetaDataProperties `json:"properties,omitempty"`
}

// UnmarshalJSON is the custom unmarshaler for AlertsMetaData struct.
func (amd *AlertsMetaData) 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 "properties":
			if v != nil {
				properties, err := unmarshalBasicAlertsMetaDataProperties(*v)
				if err != nil {
					return err
				}
				amd.Properties = properties
			}
		}
	}

	return nil
}

// BasicAlertsMetaDataProperties alert meta data property bag
type BasicAlertsMetaDataProperties interface {
	AsMonitorServiceList() (*MonitorServiceList, bool)
	AsAlertsMetaDataProperties() (*AlertsMetaDataProperties, bool)
}

// AlertsMetaDataProperties alert meta data property bag
type AlertsMetaDataProperties struct {
	// MetadataIdentifier - Possible values include: 'MetadataIdentifierAlertsMetaDataProperties', 'MetadataIdentifierMonitorServiceList'
	MetadataIdentifier MetadataIdentifier `json:"metadataIdentifier,omitempty"`
}

func unmarshalBasicAlertsMetaDataProperties(body []byte) (BasicAlertsMetaDataProperties, error) {
	var m map[string]interface{}
	err := json.Unmarshal(body, &m)
	if err != nil {
		return nil, err
	}

	switch m["metadataIdentifier"] {
	case string(MetadataIdentifierMonitorServiceList):
		var msl MonitorServiceList
		err := json.Unmarshal(body, &msl)
		return msl, err
	default:
		var amdp AlertsMetaDataProperties
		err := json.Unmarshal(body, &amdp)
		return amdp, err
	}
}
func unmarshalBasicAlertsMetaDataPropertiesArray(body []byte) ([]BasicAlertsMetaDataProperties, error) {
	var rawMessages []*json.RawMessage
	err := json.Unmarshal(body, &rawMessages)
	if err != nil {
		return nil, err
	}

	amdpArray := make([]BasicAlertsMetaDataProperties, len(rawMessages))

	for index, rawMessage := range rawMessages {
		amdp, err := unmarshalBasicAlertsMetaDataProperties(*rawMessage)
		if err != nil {
			return nil, err
		}
		amdpArray[index] = amdp
	}
	return amdpArray, nil
}

// MarshalJSON is the custom marshaler for AlertsMetaDataProperties.
func (amdp AlertsMetaDataProperties) MarshalJSON() ([]byte, error) {
	amdp.MetadataIdentifier = MetadataIdentifierAlertsMetaDataProperties
	objectMap := make(map[string]interface{})
	if amdp.MetadataIdentifier != "" {
		objectMap["metadataIdentifier"] = amdp.MetadataIdentifier
	}
	return json.Marshal(objectMap)
}

// AsMonitorServiceList is the BasicAlertsMetaDataProperties implementation for AlertsMetaDataProperties.
func (amdp AlertsMetaDataProperties) AsMonitorServiceList() (*MonitorServiceList, bool) {
	return nil, false
}

// AsAlertsMetaDataProperties is the BasicAlertsMetaDataProperties implementation for AlertsMetaDataProperties.
func (amdp AlertsMetaDataProperties) AsAlertsMetaDataProperties() (*AlertsMetaDataProperties, bool) {
	return &amdp, true
}

// AsBasicAlertsMetaDataProperties is the BasicAlertsMetaDataProperties implementation for AlertsMetaDataProperties.
func (amdp AlertsMetaDataProperties) AsBasicAlertsMetaDataProperties() (BasicAlertsMetaDataProperties, bool) {
	return &amdp, true
}

// AlertsSummary summary of alerts based on the input filters and 'groupby' parameters.
type AlertsSummary struct {
	autorest.Response `json:"-"`
	Properties        *AlertsSummaryGroup `json:"properties,omitempty"`
	// ID - READ-ONLY; Azure resource Id
	ID *string `json:"id,omitempty"`
	// Type - READ-ONLY; Azure resource type
	Type *string `json:"type,omitempty"`
	// Name - READ-ONLY; Azure resource name
	Name *string `json:"name,omitempty"`
}

// MarshalJSON is the custom marshaler for AlertsSummary.
func (as AlertsSummary) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	if as.Properties != nil {
		objectMap["properties"] = as.Properties
	}
	return json.Marshal(objectMap)
}

// AlertsSummaryGroup group the result set.
type AlertsSummaryGroup struct {
	// Total - Total count of the result set.
	Total *int32 `json:"total,omitempty"`
	// SmartGroupsCount - Total count of the smart groups.
	SmartGroupsCount *int32 `json:"smartGroupsCount,omitempty"`
	// Groupedby - Name of the field aggregated
	Groupedby *string `json:"groupedby,omitempty"`
	// Values - List of the items
	Values *[]AlertsSummaryGroupItem `json:"values,omitempty"`
}

// AlertsSummaryGroupItem alerts summary group item
type AlertsSummaryGroupItem struct {
	// Name - Value of the aggregated field
	Name *string `json:"name,omitempty"`
	// Count - Count of the aggregated field
	Count *int32 `json:"count,omitempty"`
	// Groupedby - Name of the field aggregated
	Groupedby *string `json:"groupedby,omitempty"`
	// Values - List of the items
	Values *[]AlertsSummaryGroupItem `json:"values,omitempty"`
}

// AzureResource an Azure resource object
type AzureResource struct {
	// ID - READ-ONLY; The resource ID.
	ID *string `json:"id,omitempty"`
	// Type - READ-ONLY; The resource type.
	Type *string `json:"type,omitempty"`
	// Name - READ-ONLY; The resource name.
	Name *string `json:"name,omitempty"`
	// Location - The resource location.
	Location *string `json:"location,omitempty"`
	// Tags - The resource tags.
	Tags map[string]*string `json:"tags"`
}

// MarshalJSON is the custom marshaler for AzureResource.
func (ar AzureResource) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	if ar.Location != nil {
		objectMap["location"] = ar.Location
	}
	if ar.Tags != nil {
		objectMap["tags"] = ar.Tags
	}
	return json.Marshal(objectMap)
}

// Bool ...
type Bool struct {
	autorest.Response `json:"-"`
	Value             *bool `json:"value,omitempty"`
}

// Condition condition to trigger an action rule
type Condition struct {
	// Operator - operator for a given condition. Possible values include: 'Equals', 'NotEquals', 'Contains', 'DoesNotContain'
	Operator Operator `json:"operator,omitempty"`
	// Values - list of values to match for a given condition.
	Values *[]string `json:"values,omitempty"`
}

// Conditions conditions in alert instance to be matched for a given action rule. Default value is all.
// Multiple values could be provided with comma separation.
type Conditions struct {
	// Severity - filter alerts by severity
	Severity *Condition `json:"severity,omitempty"`
	// MonitorService - filter alerts by monitor service
	MonitorService *Condition `json:"monitorService,omitempty"`
	// MonitorCondition - filter alerts by monitor condition
	MonitorCondition *Condition `json:"monitorCondition,omitempty"`
	// TargetResourceType - filter alerts by target resource type
	TargetResourceType *Condition `json:"targetResourceType,omitempty"`
	// AlertRuleID - filter alerts by alert rule id
	AlertRuleID *Condition `json:"alertRuleId,omitempty"`
	// Description - filter alerts by alert rule description
	Description *Condition `json:"description,omitempty"`
	// AlertContext - filter alerts by alert context (payload)
	AlertContext *Condition `json:"alertContext,omitempty"`
}

// Detector the detector information. By default this is not populated, unless it's specified in
// expandDetector
type Detector struct {
	// ID - The detector id.
	ID *string `json:"id,omitempty"`
	// Parameters - The detector's parameters.'
	Parameters map[string]interface{} `json:"parameters"`
	// Name - The Smart Detector name. By default this is not populated, unless it's specified in expandDetector
	Name *string `json:"name,omitempty"`
	// Description - The Smart Detector description. By default this is not populated, unless it's specified in expandDetector
	Description *string `json:"description,omitempty"`
	// SupportedResourceTypes - The Smart Detector supported resource types. By default this is not populated, unless it's specified in expandDetector
	SupportedResourceTypes *[]string `json:"supportedResourceTypes,omitempty"`
	// ImagePaths - The Smart Detector image path. By default this is not populated, unless it's specified in expandDetector
	ImagePaths *[]string `json:"imagePaths,omitempty"`
}

// MarshalJSON is the custom marshaler for Detector.
func (d Detector) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	if d.ID != nil {
		objectMap["id"] = d.ID
	}
	if d.Parameters != nil {
		objectMap["parameters"] = d.Parameters
	}
	if d.Name != nil {
		objectMap["name"] = d.Name
	}
	if d.Description != nil {
		objectMap["description"] = d.Description
	}
	if d.SupportedResourceTypes != nil {
		objectMap["supportedResourceTypes"] = d.SupportedResourceTypes
	}
	if d.ImagePaths != nil {
		objectMap["imagePaths"] = d.ImagePaths
	}
	return json.Marshal(objectMap)
}

// Diagnostics action rule with diagnostics configuration
type Diagnostics struct {
	// Scope - scope on which action rule will apply
	Scope *Scope `json:"scope,omitempty"`
	// Conditions - conditions on which alerts will be filtered
	Conditions *Conditions `json:"conditions,omitempty"`
	// Description - Description of action rule
	Description *string `json:"description,omitempty"`
	// CreatedAt - READ-ONLY; Creation time of action rule. Date-Time in ISO-8601 format.
	CreatedAt *date.Time `json:"createdAt,omitempty"`
	// LastModifiedAt - READ-ONLY; Last updated time of action rule. Date-Time in ISO-8601 format.
	LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"`
	// CreatedBy - READ-ONLY; Created by user name.
	CreatedBy *string `json:"createdBy,omitempty"`
	// LastModifiedBy - READ-ONLY; Last modified by user name.
	LastModifiedBy *string `json:"lastModifiedBy,omitempty"`
	// Status - Indicates if the given action rule is enabled or disabled. Possible values include: 'Enabled', 'Disabled'
	Status ActionRuleStatus `json:"status,omitempty"`
	// Type - Possible values include: 'TypeActionRuleProperties', 'TypeSuppression', 'TypeActionGroup', 'TypeDiagnostics'
	Type Type `json:"type,omitempty"`
}

// MarshalJSON is the custom marshaler for Diagnostics.
func (d Diagnostics) MarshalJSON() ([]byte, error) {
	d.Type = TypeDiagnostics
	objectMap := make(map[string]interface{})
	if d.Scope != nil {
		objectMap["scope"] = d.Scope
	}
	if d.Conditions != nil {
		objectMap["conditions"] = d.Conditions
	}
	if d.Description != nil {
		objectMap["description"] = d.Description
	}
	if d.Status != "" {
		objectMap["status"] = d.Status
	}
	if d.Type != "" {
		objectMap["type"] = d.Type
	}
	return json.Marshal(objectMap)
}

// AsSuppression is the BasicActionRuleProperties implementation for Diagnostics.
func (d Diagnostics) AsSuppression() (*Suppression, bool) {
	return nil, false
}

// AsActionGroup is the BasicActionRuleProperties implementation for Diagnostics.
func (d Diagnostics) AsActionGroup() (*ActionGroup, bool) {
	return nil, false
}

// AsDiagnostics is the BasicActionRuleProperties implementation for Diagnostics.
func (d Diagnostics) AsDiagnostics() (*Diagnostics, bool) {
	return &d, true
}

// AsActionRuleProperties is the BasicActionRuleProperties implementation for Diagnostics.
func (d Diagnostics) AsActionRuleProperties() (*ActionRuleProperties, bool) {
	return nil, false
}

// AsBasicActionRuleProperties is the BasicActionRuleProperties implementation for Diagnostics.
func (d Diagnostics) AsBasicActionRuleProperties() (BasicActionRuleProperties, bool) {
	return &d, true
}

// ErrorResponse an error response from the service.
type ErrorResponse struct {
	Error *ErrorResponseBody `json:"error,omitempty"`
}

// ErrorResponseBody details of error response.
type ErrorResponseBody struct {
	// Code - Error code, intended to be consumed programmatically.
	Code *string `json:"code,omitempty"`
	// Message - Description of the error, intended for display in user interface.
	Message *string `json:"message,omitempty"`
	// Target - Target of the particular error, for example name of the property.
	Target *string `json:"target,omitempty"`
	// Details - A list of additional details about the error.
	Details *[]ErrorResponseBody `json:"details,omitempty"`
}

// Essentials this object contains consistent fields across different monitor services.
type Essentials struct {
	// Severity - READ-ONLY; Severity of alert Sev0 being highest and Sev4 being lowest. Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4'
	Severity Severity `json:"severity,omitempty"`
	// SignalType - READ-ONLY; The type of signal the alert is based on, which could be metrics, logs or activity logs. Possible values include: 'Metric', 'Log', 'Unknown'
	SignalType SignalType `json:"signalType,omitempty"`
	// AlertState - READ-ONLY; Alert object state, which can be modified by the user. Possible values include: 'AlertStateNew', 'AlertStateAcknowledged', 'AlertStateClosed'
	AlertState AlertState `json:"alertState,omitempty"`
	// MonitorCondition - READ-ONLY; Condition of the rule at the monitor service. It represents whether the underlying conditions have crossed the defined alert rule thresholds. Possible values include: 'Fired', 'Resolved'
	MonitorCondition MonitorCondition `json:"monitorCondition,omitempty"`
	// TargetResource - Target ARM resource, on which alert got created.
	TargetResource *string `json:"targetResource,omitempty"`
	// TargetResourceName - Name of the target ARM resource name, on which alert got created.
	TargetResourceName *string `json:"targetResourceName,omitempty"`
	// TargetResourceGroup - Resource group of target ARM resource, on which alert got created.
	TargetResourceGroup *string `json:"targetResourceGroup,omitempty"`
	// TargetResourceType - Resource type of target ARM resource, on which alert got created.
	TargetResourceType *string `json:"targetResourceType,omitempty"`
	// MonitorService - READ-ONLY; Monitor service on which the rule(monitor) is set. Possible values include: 'ApplicationInsights', 'ActivityLogAdministrative', 'ActivityLogSecurity', 'ActivityLogRecommendation', 'ActivityLogPolicy', 'ActivityLogAutoscale', 'LogAnalytics', 'Nagios', 'Platform', 'SCOM', 'ServiceHealth', 'SmartDetector', 'VMInsights', 'Zabbix'
	MonitorService MonitorService `json:"monitorService,omitempty"`
	// AlertRule - READ-ONLY; Rule(monitor) which fired alert instance. Depending on the monitor service,  this would be ARM id or name of the rule.
	AlertRule *string `json:"alertRule,omitempty"`
	// SourceCreatedID - READ-ONLY; Unique Id created by monitor service for each alert instance. This could be used to track the issue at the monitor service, in case of Nagios, Zabbix, SCOM etc.
	SourceCreatedID *string `json:"sourceCreatedId,omitempty"`
	// SmartGroupID - READ-ONLY; Unique Id of the smart group
	SmartGroupID *string `json:"smartGroupId,omitempty"`
	// SmartGroupingReason - READ-ONLY; Verbose reason describing the reason why this alert instance is added to a smart group
	SmartGroupingReason *string `json:"smartGroupingReason,omitempty"`
	// StartDateTime - READ-ONLY; Creation time(ISO-8601 format) of alert instance.
	StartDateTime *date.Time `json:"startDateTime,omitempty"`
	// LastModifiedDateTime - READ-ONLY; Last modification time(ISO-8601 format) of alert instance.
	LastModifiedDateTime *date.Time `json:"lastModifiedDateTime,omitempty"`
	// MonitorConditionResolvedDateTime - READ-ONLY; Resolved time(ISO-8601 format) of alert instance. This will be updated when monitor service resolves the alert instance because the rule condition is no longer met.
	MonitorConditionResolvedDateTime *date.Time `json:"monitorConditionResolvedDateTime,omitempty"`
	// LastModifiedUserName - READ-ONLY; User who last modified the alert, in case of monitor service updates user would be 'system', otherwise name of the user.
	LastModifiedUserName *string `json:"lastModifiedUserName,omitempty"`
}

// MarshalJSON is the custom marshaler for Essentials.
func (e Essentials) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	if e.TargetResource != nil {
		objectMap["targetResource"] = e.TargetResource
	}
	if e.TargetResourceName != nil {
		objectMap["targetResourceName"] = e.TargetResourceName
	}
	if e.TargetResourceGroup != nil {
		objectMap["targetResourceGroup"] = e.TargetResourceGroup
	}
	if e.TargetResourceType != nil {
		objectMap["targetResourceType"] = e.TargetResourceType
	}
	return json.Marshal(objectMap)
}

// ManagedResource an azure managed resource object
type ManagedResource struct {
	// Location - Resource location
	Location *string `json:"location,omitempty"`
	// Tags - Resource tags
	Tags map[string]*string `json:"tags"`
	// ID - READ-ONLY; Azure resource Id
	ID *string `json:"id,omitempty"`
	// Type - READ-ONLY; Azure resource type
	Type *string `json:"type,omitempty"`
	// Name - READ-ONLY; Azure resource name
	Name *string `json:"name,omitempty"`
}

// MarshalJSON is the custom marshaler for ManagedResource.
func (mr ManagedResource) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	if mr.Location != nil {
		objectMap["location"] = mr.Location
	}
	if mr.Tags != nil {
		objectMap["tags"] = mr.Tags
	}
	return json.Marshal(objectMap)
}

// MonitorServiceDetails details of a monitor service
type MonitorServiceDetails struct {
	// Name - Monitor service name
	Name *string `json:"name,omitempty"`
	// DisplayName - Monitor service display name
	DisplayName *string `json:"displayName,omitempty"`
}

// MonitorServiceList monitor service details
type MonitorServiceList struct {
	// Data - Array of operations
	Data *[]MonitorServiceDetails `json:"data,omitempty"`
	// MetadataIdentifier - Possible values include: 'MetadataIdentifierAlertsMetaDataProperties', 'MetadataIdentifierMonitorServiceList'
	MetadataIdentifier MetadataIdentifier `json:"metadataIdentifier,omitempty"`
}

// MarshalJSON is the custom marshaler for MonitorServiceList.
func (msl MonitorServiceList) MarshalJSON() ([]byte, error) {
	msl.MetadataIdentifier = MetadataIdentifierMonitorServiceList
	objectMap := make(map[string]interface{})
	if msl.Data != nil {
		objectMap["data"] = msl.Data
	}
	if msl.MetadataIdentifier != "" {
		objectMap["metadataIdentifier"] = msl.MetadataIdentifier
	}
	return json.Marshal(objectMap)
}

// AsMonitorServiceList is the BasicAlertsMetaDataProperties implementation for MonitorServiceList.
func (msl MonitorServiceList) AsMonitorServiceList() (*MonitorServiceList, bool) {
	return &msl, true
}

// AsAlertsMetaDataProperties is the BasicAlertsMetaDataProperties implementation for MonitorServiceList.
func (msl MonitorServiceList) AsAlertsMetaDataProperties() (*AlertsMetaDataProperties, bool) {
	return nil, false
}

// AsBasicAlertsMetaDataProperties is the BasicAlertsMetaDataProperties implementation for MonitorServiceList.
func (msl MonitorServiceList) AsBasicAlertsMetaDataProperties() (BasicAlertsMetaDataProperties, bool) {
	return &msl, true
}

// Operation operation provided by provider
type Operation struct {
	// Name - Name of the operation
	Name *string `json:"name,omitempty"`
	// Display - Properties of the operation
	Display *OperationDisplay `json:"display,omitempty"`
}

// OperationDisplay properties of the operation
type OperationDisplay struct {
	// Provider - Provider name
	Provider *string `json:"provider,omitempty"`
	// Resource - Resource name
	Resource *string `json:"resource,omitempty"`
	// Operation - Operation name
	Operation *string `json:"operation,omitempty"`
	// Description - Description of the operation
	Description *string `json:"description,omitempty"`
}

// OperationsList lists the operations available in the AlertsManagement RP.
type OperationsList struct {
	autorest.Response `json:"-"`
	// NextLink - URL to fetch the next set of alerts.
	NextLink *string `json:"nextLink,omitempty"`
	// Value - Array of operations
	Value *[]Operation `json:"value,omitempty"`
}

// OperationsListIterator provides access to a complete listing of Operation values.
type OperationsListIterator struct {
	i    int
	page OperationsListPage
}

// NextWithContext advances to the next value.  If there was an error making
// the request the iterator does not advance and the error is returned.
func (iter *OperationsListIterator) NextWithContext(ctx context.Context) (err error) {
	if tracing.IsEnabled() {
		ctx = tracing.StartSpan(ctx, fqdn+"/OperationsListIterator.NextWithContext")
		defer func() {
			sc := -1
			if iter.Response().Response.Response != nil {
				sc = iter.Response().Response.Response.StatusCode
			}
			tracing.EndSpan(ctx, sc, err)
		}()
	}
	iter.i++
	if iter.i < len(iter.page.Values()) {
		return nil
	}
	err = iter.page.NextWithContext(ctx)
	if err != nil {
		iter.i--
		return err
	}
	iter.i = 0
	return nil
}

// Next advances to the next value.  If there was an error making
// the request the iterator does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (iter *OperationsListIterator) Next() error {
	return iter.NextWithContext(context.Background())
}

// NotDone returns true if the enumeration should be started or is not yet complete.
func (iter OperationsListIterator) NotDone() bool {
	return iter.page.NotDone() && iter.i < len(iter.page.Values())
}

// Response returns the raw server response from the last page request.
func (iter OperationsListIterator) Response() OperationsList {
	return iter.page.Response()
}

// Value returns the current value or a zero-initialized value if the
// iterator has advanced beyond the end of the collection.
func (iter OperationsListIterator) Value() Operation {
	if !iter.page.NotDone() {
		return Operation{}
	}
	return iter.page.Values()[iter.i]
}

// Creates a new instance of the OperationsListIterator type.
func NewOperationsListIterator(page OperationsListPage) OperationsListIterator {
	return OperationsListIterator{page: page}
}

// IsEmpty returns true if the ListResult contains no values.
func (ol OperationsList) IsEmpty() bool {
	return ol.Value == nil || len(*ol.Value) == 0
}

// hasNextLink returns true if the NextLink is not empty.
func (ol OperationsList) hasNextLink() bool {
	return ol.NextLink != nil && len(*ol.NextLink) != 0
}

// operationsListPreparer prepares a request to retrieve the next set of results.
// It returns nil if no more results exist.
func (ol OperationsList) operationsListPreparer(ctx context.Context) (*http.Request, error) {
	if !ol.hasNextLink() {
		return nil, nil
	}
	return autorest.Prepare((&http.Request{}).WithContext(ctx),
		autorest.AsJSON(),
		autorest.AsGet(),
		autorest.WithBaseURL(to.String(ol.NextLink)))
}

// OperationsListPage contains a page of Operation values.
type OperationsListPage struct {
	fn func(context.Context, OperationsList) (OperationsList, error)
	ol OperationsList
}

// NextWithContext advances to the next page of values.  If there was an error making
// the request the page does not advance and the error is returned.
func (page *OperationsListPage) NextWithContext(ctx context.Context) (err error) {
	if tracing.IsEnabled() {
		ctx = tracing.StartSpan(ctx, fqdn+"/OperationsListPage.NextWithContext")
		defer func() {
			sc := -1
			if page.Response().Response.Response != nil {
				sc = page.Response().Response.Response.StatusCode
			}
			tracing.EndSpan(ctx, sc, err)
		}()
	}
	for {
		next, err := page.fn(ctx, page.ol)
		if err != nil {
			return err
		}
		page.ol = next
		if !next.hasNextLink() || !next.IsEmpty() {
			break
		}
	}
	return nil
}

// Next advances to the next page of values.  If there was an error making
// the request the page does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (page *OperationsListPage) Next() error {
	return page.NextWithContext(context.Background())
}

// NotDone returns true if the page enumeration should be started or is not yet complete.
func (page OperationsListPage) NotDone() bool {
	return !page.ol.IsEmpty()
}

// Response returns the raw server response from the last page request.
func (page OperationsListPage) Response() OperationsList {
	return page.ol
}

// Values returns the slice of values for the current page or nil if there are no values.
func (page OperationsListPage) Values() []Operation {
	if page.ol.IsEmpty() {
		return nil
	}
	return *page.ol.Value
}

// Creates a new instance of the OperationsListPage type.
func NewOperationsListPage(cur OperationsList, getNextPage func(context.Context, OperationsList) (OperationsList, error)) OperationsListPage {
	return OperationsListPage{
		fn: getNextPage,
		ol: cur,
	}
}

// PatchObject data contract for patch
type PatchObject struct {
	// PatchProperties - properties supported by patch operation
	*PatchProperties `json:"properties,omitempty"`
	// Tags - tags to be updated
	Tags interface{} `json:"tags,omitempty"`
}

// MarshalJSON is the custom marshaler for PatchObject.
func (po PatchObject) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	if po.PatchProperties != nil {
		objectMap["properties"] = po.PatchProperties
	}
	if po.Tags != nil {
		objectMap["tags"] = po.Tags
	}
	return json.Marshal(objectMap)
}

// UnmarshalJSON is the custom unmarshaler for PatchObject struct.
func (po *PatchObject) 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 "properties":
			if v != nil {
				var patchProperties PatchProperties
				err = json.Unmarshal(*v, &patchProperties)
				if err != nil {
					return err
				}
				po.PatchProperties = &patchProperties
			}
		case "tags":
			if v != nil {
				var tags interface{}
				err = json.Unmarshal(*v, &tags)
				if err != nil {
					return err
				}
				po.Tags = tags
			}
		}
	}

	return nil
}

// PatchProperties action rule properties supported by patch
type PatchProperties struct {
	// Status - Indicates if the given action rule is enabled or disabled. Possible values include: 'Enabled', 'Disabled'
	Status ActionRuleStatus `json:"status,omitempty"`
}

// Resource an azure resource object
type Resource struct {
	// ID - READ-ONLY; Azure resource Id
	ID *string `json:"id,omitempty"`
	// Type - READ-ONLY; Azure resource type
	Type *string `json:"type,omitempty"`
	// Name - READ-ONLY; Azure resource name
	Name *string `json:"name,omitempty"`
}

// MarshalJSON is the custom marshaler for Resource.
func (r Resource) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	return json.Marshal(objectMap)
}

// Scope target scope for a given action rule. By default scope will be the subscription. User can also
// provide list of resource groups or list of resources from the scope subscription as well.
type Scope struct {
	// ScopeType - type of target scope. Possible values include: 'ScopeTypeResourceGroup', 'ScopeTypeResource', 'ScopeTypeSubscription'
	ScopeType ScopeType `json:"scopeType,omitempty"`
	// Values - list of ARM IDs of the given scope type which will be the target of the given action rule.
	Values *[]string `json:"values,omitempty"`
}

// SmartDetectorErrorResponse describe the format of an Error response.
type SmartDetectorErrorResponse struct {
	// Code - Error code
	Code *string `json:"code,omitempty"`
	// Message - Error message indicating why the operation failed.
	Message *string `json:"message,omitempty"`
}

// SmartGroup set of related alerts grouped together smartly by AMS.
type SmartGroup struct {
	autorest.Response     `json:"-"`
	*SmartGroupProperties `json:"properties,omitempty"`
	// ID - READ-ONLY; Azure resource Id
	ID *string `json:"id,omitempty"`
	// Type - READ-ONLY; Azure resource type
	Type *string `json:"type,omitempty"`
	// Name - READ-ONLY; Azure resource name
	Name *string `json:"name,omitempty"`
}

// MarshalJSON is the custom marshaler for SmartGroup.
func (sg SmartGroup) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	if sg.SmartGroupProperties != nil {
		objectMap["properties"] = sg.SmartGroupProperties
	}
	return json.Marshal(objectMap)
}

// UnmarshalJSON is the custom unmarshaler for SmartGroup struct.
func (sg *SmartGroup) 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 "properties":
			if v != nil {
				var smartGroupProperties SmartGroupProperties
				err = json.Unmarshal(*v, &smartGroupProperties)
				if err != nil {
					return err
				}
				sg.SmartGroupProperties = &smartGroupProperties
			}
		case "id":
			if v != nil {
				var ID string
				err = json.Unmarshal(*v, &ID)
				if err != nil {
					return err
				}
				sg.ID = &ID
			}
		case "type":
			if v != nil {
				var typeVar string
				err = json.Unmarshal(*v, &typeVar)
				if err != nil {
					return err
				}
				sg.Type = &typeVar
			}
		case "name":
			if v != nil {
				var name string
				err = json.Unmarshal(*v, &name)
				if err != nil {
					return err
				}
				sg.Name = &name
			}
		}
	}

	return nil
}

// SmartGroupAggregatedProperty aggregated property of each type
type SmartGroupAggregatedProperty struct {
	// Name - Name of the type.
	Name *string `json:"name,omitempty"`
	// Count - Total number of items of type.
	Count *int32 `json:"count,omitempty"`
}

// SmartGroupModification alert Modification details
type SmartGroupModification struct {
	autorest.Response `json:"-"`
	Properties        *SmartGroupModificationProperties `json:"properties,omitempty"`
	// ID - READ-ONLY; Azure resource Id
	ID *string `json:"id,omitempty"`
	// Type - READ-ONLY; Azure resource type
	Type *string `json:"type,omitempty"`
	// Name - READ-ONLY; Azure resource name
	Name *string `json:"name,omitempty"`
}

// MarshalJSON is the custom marshaler for SmartGroupModification.
func (sgm SmartGroupModification) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	if sgm.Properties != nil {
		objectMap["properties"] = sgm.Properties
	}
	return json.Marshal(objectMap)
}

// SmartGroupModificationItem smartGroup modification item.
type SmartGroupModificationItem struct {
	// ModificationEvent - Reason for the modification. Possible values include: 'SmartGroupModificationEventSmartGroupCreated', 'SmartGroupModificationEventStateChange', 'SmartGroupModificationEventAlertAdded', 'SmartGroupModificationEventAlertRemoved'
	ModificationEvent SmartGroupModificationEvent `json:"modificationEvent,omitempty"`
	// OldValue - Old value
	OldValue *string `json:"oldValue,omitempty"`
	// NewValue - New value
	NewValue *string `json:"newValue,omitempty"`
	// ModifiedAt - Modified date and time
	ModifiedAt *string `json:"modifiedAt,omitempty"`
	// ModifiedBy - Modified user details (Principal client name)
	ModifiedBy *string `json:"modifiedBy,omitempty"`
	// Comments - Modification comments
	Comments *string `json:"comments,omitempty"`
	// Description - Description of the modification
	Description *string `json:"description,omitempty"`
}

// SmartGroupModificationProperties properties of the smartGroup modification item.
type SmartGroupModificationProperties struct {
	// SmartGroupID - READ-ONLY; Unique Id of the smartGroup for which the history is being retrieved
	SmartGroupID *string `json:"smartGroupId,omitempty"`
	// Modifications - Modification details
	Modifications *[]SmartGroupModificationItem `json:"modifications,omitempty"`
	// NextLink - URL to fetch the next set of results.
	NextLink *string `json:"nextLink,omitempty"`
}

// MarshalJSON is the custom marshaler for SmartGroupModificationProperties.
func (sgmp SmartGroupModificationProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	if sgmp.Modifications != nil {
		objectMap["modifications"] = sgmp.Modifications
	}
	if sgmp.NextLink != nil {
		objectMap["nextLink"] = sgmp.NextLink
	}
	return json.Marshal(objectMap)
}

// SmartGroupProperties properties of smart group.
type SmartGroupProperties struct {
	// AlertsCount - Total number of alerts in smart group
	AlertsCount *int32 `json:"alertsCount,omitempty"`
	// SmartGroupState - READ-ONLY; Smart group state. Possible values include: 'StateNew', 'StateAcknowledged', 'StateClosed'
	SmartGroupState State `json:"smartGroupState,omitempty"`
	// Severity - READ-ONLY; Severity of smart group is the highest(Sev0 >... > Sev4) severity of all the alerts in the group. Possible values include: 'Sev0', 'Sev1', 'Sev2', 'Sev3', 'Sev4'
	Severity Severity `json:"severity,omitempty"`
	// StartDateTime - READ-ONLY; Creation time of smart group. Date-Time in ISO-8601 format.
	StartDateTime *date.Time `json:"startDateTime,omitempty"`
	// LastModifiedDateTime - READ-ONLY; Last updated time of smart group. Date-Time in ISO-8601 format.
	LastModifiedDateTime *date.Time `json:"lastModifiedDateTime,omitempty"`
	// LastModifiedUserName - READ-ONLY; Last modified by user name.
	LastModifiedUserName *string `json:"lastModifiedUserName,omitempty"`
	// Resources - Summary of target resources in the smart group
	Resources *[]SmartGroupAggregatedProperty `json:"resources,omitempty"`
	// ResourceTypes - Summary of target resource types in the smart group
	ResourceTypes *[]SmartGroupAggregatedProperty `json:"resourceTypes,omitempty"`
	// ResourceGroups - Summary of target resource groups in the smart group
	ResourceGroups *[]SmartGroupAggregatedProperty `json:"resourceGroups,omitempty"`
	// MonitorServices - Summary of monitorServices in the smart group
	MonitorServices *[]SmartGroupAggregatedProperty `json:"monitorServices,omitempty"`
	// MonitorConditions - Summary of monitorConditions in the smart group
	MonitorConditions *[]SmartGroupAggregatedProperty `json:"monitorConditions,omitempty"`
	// AlertStates - Summary of alertStates in the smart group
	AlertStates *[]SmartGroupAggregatedProperty `json:"alertStates,omitempty"`
	// AlertSeverities - Summary of alertSeverities in the smart group
	AlertSeverities *[]SmartGroupAggregatedProperty `json:"alertSeverities,omitempty"`
	// NextLink - The URI to fetch the next page of alerts. Call ListNext() with this URI to fetch the next page alerts.
	NextLink *string `json:"nextLink,omitempty"`
}

// MarshalJSON is the custom marshaler for SmartGroupProperties.
func (sgp SmartGroupProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]interface{})
	if sgp.AlertsCount != nil {
		objectMap["alertsCount"] = sgp.AlertsCount
	}
	if sgp.Resources != nil {
		objectMap["resources"] = sgp.Resources
	}
	if sgp.ResourceTypes != nil {
		objectMap["resourceTypes"] = sgp.ResourceTypes
	}
	if sgp.ResourceGroups != nil {
		objectMap["resourceGroups"] = sgp.ResourceGroups
	}
	if sgp.MonitorServices != nil {
		objectMap["monitorServices"] = sgp.MonitorServices
	}
	if sgp.MonitorConditions != nil {
		objectMap["monitorConditions"] = sgp.MonitorConditions
	}
	if sgp.AlertStates != nil {
		objectMap["alertStates"] = sgp.AlertStates
	}
	if sgp.AlertSeverities != nil {
		objectMap["alertSeverities"] = sgp.AlertSeverities
	}
	if sgp.NextLink != nil {
		objectMap["nextLink"] = sgp.NextLink
	}
	return json.Marshal(objectMap)
}

// SmartGroupsList list the alerts.
type SmartGroupsList struct {
	autorest.Response `json:"-"`
	// NextLink - URL to fetch the next set of alerts.
	NextLink *string `json:"nextLink,omitempty"`
	// Value - List of alerts
	Value *[]SmartGroup `json:"value,omitempty"`
}

// SmartGroupsListIterator provides access to a complete listing of SmartGroup values.
type SmartGroupsListIterator struct {
	i    int
	page SmartGroupsListPage
}

// NextWithContext advances to the next value.  If there was an error making
// the request the iterator does not advance and the error is returned.
func (iter *SmartGroupsListIterator) NextWithContext(ctx context.Context) (err error) {
	if tracing.IsEnabled() {
		ctx = tracing.StartSpan(ctx, fqdn+"/SmartGroupsListIterator.NextWithContext")
		defer func() {
			sc := -1
			if iter.Response().Response.Response != nil {
				sc = iter.Response().Response.Response.StatusCode
			}
			tracing.EndSpan(ctx, sc, err)
		}()
	}
	iter.i++
	if iter.i < len(iter.page.Values()) {
		return nil
	}
	err = iter.page.NextWithContext(ctx)
	if err != nil {
		iter.i--
		return err
	}
	iter.i = 0
	return nil
}

// Next advances to the next value.  If there was an error making
// the request the iterator does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (iter *SmartGroupsListIterator) Next() error {
	return iter.NextWithContext(context.Background())
}

// NotDone returns true if the enumeration should be started or is not yet complete.
func (iter SmartGroupsListIterator) NotDone() bool {
	return iter.page.NotDone() && iter.i < len(iter.page.Values())
}

// Response returns the raw server response from the last page request.
func (iter SmartGroupsListIterator) Response() SmartGroupsList {
	return iter.page.Response()
}

// Value returns the current value or a zero-initialized value if the
// iterator has advanced beyond the end of the collection.
func (iter SmartGroupsListIterator) Value() SmartGroup {
	if !iter.page.NotDone() {
		return SmartGroup{}
	}
	return iter.page.Values()[iter.i]
}

// Creates a new instance of the SmartGroupsListIterator type.
func NewSmartGroupsListIterator(page SmartGroupsListPage) SmartGroupsListIterator {
	return SmartGroupsListIterator{page: page}
}

// IsEmpty returns true if the ListResult contains no values.
func (sgl SmartGroupsList) IsEmpty() bool {
	return sgl.Value == nil || len(*sgl.Value) == 0
}

// hasNextLink returns true if the NextLink is not empty.
func (sgl SmartGroupsList) hasNextLink() bool {
	return sgl.NextLink != nil && len(*sgl.NextLink) != 0
}

// smartGroupsListPreparer prepares a request to retrieve the next set of results.
// It returns nil if no more results exist.
func (sgl SmartGroupsList) smartGroupsListPreparer(ctx context.Context) (*http.Request, error) {
	if !sgl.hasNextLink() {
		return nil, nil
	}
	return autorest.Prepare((&http.Request{}).WithContext(ctx),
		autorest.AsJSON(),
		autorest.AsGet(),
		autorest.WithBaseURL(to.String(sgl.NextLink)))
}

// SmartGroupsListPage contains a page of SmartGroup values.
type SmartGroupsListPage struct {
	fn  func(context.Context, SmartGroupsList) (SmartGroupsList, error)
	sgl SmartGroupsList
}

// NextWithContext advances to the next page of values.  If there was an error making
// the request the page does not advance and the error is returned.
func (page *SmartGroupsListPage) NextWithContext(ctx context.Context) (err error) {
	if tracing.IsEnabled() {
		ctx = tracing.StartSpan(ctx, fqdn+"/SmartGroupsListPage.NextWithContext")
		defer func() {
			sc := -1
			if page.Response().Response.Response != nil {
				sc = page.Response().Response.Response.StatusCode
			}
			tracing.EndSpan(ctx, sc, err)
		}()
	}
	for {
		next, err := page.fn(ctx, page.sgl)
		if err != nil {
			return err
		}
		page.sgl = next
		if !next.hasNextLink() || !next.IsEmpty() {
			break
		}
	}
	return nil
}

// Next advances to the next page of values.  If there was an error making
// the request the page does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (page *SmartGroupsListPage) Next() error {
	return page.NextWithContext(context.Background())
}

// NotDone returns true if the page enumeration should be started or is not yet complete.
func (page SmartGroupsListPage) NotDone() bool {
	return !page.sgl.IsEmpty()
}

// Response returns the raw server response from the last page request.
func (page SmartGroupsListPage) Response() SmartGroupsList {
	return page.sgl
}

// Values returns the slice of values for the current page or nil if there are no values.
func (page SmartGroupsListPage) Values() []SmartGroup {
	if page.sgl.IsEmpty() {
		return nil
	}
	return *page.sgl.Value
}

// Creates a new instance of the SmartGroupsListPage type.
func NewSmartGroupsListPage(cur SmartGroupsList, getNextPage func(context.Context, SmartGroupsList) (SmartGroupsList, error)) SmartGroupsListPage {
	return SmartGroupsListPage{
		fn:  getNextPage,
		sgl: cur,
	}
}

// Suppression action rule with suppression configuration
type Suppression struct {
	// SuppressionConfig - suppression configuration for the action rule
	SuppressionConfig *SuppressionConfig `json:"suppressionConfig,omitempty"`
	// Scope - scope on which action rule will apply
	Scope *Scope `json:"scope,omitempty"`
	// Conditions - conditions on which alerts will be filtered
	Conditions *Conditions `json:"conditions,omitempty"`
	// Description - Description of action rule
	Description *string `json:"description,omitempty"`
	// CreatedAt - READ-ONLY; Creation time of action rule. Date-Time in ISO-8601 format.
	CreatedAt *date.Time `json:"createdAt,omitempty"`
	// LastModifiedAt - READ-ONLY; Last updated time of action rule. Date-Time in ISO-8601 format.
	LastModifiedAt *date.Time `json:"lastModifiedAt,omitempty"`
	// CreatedBy - READ-ONLY; Created by user name.
	CreatedBy *string `json:"createdBy,omitempty"`
	// LastModifiedBy - READ-ONLY; Last modified by user name.
	LastModifiedBy *string `json:"lastModifiedBy,omitempty"`
	// Status - Indicates if the given action rule is enabled or disabled. Possible values include: 'Enabled', 'Disabled'
	Status ActionRuleStatus `json:"status,omitempty"`
	// Type - Possible values include: 'TypeActionRuleProperties', 'TypeSuppression', 'TypeActionGroup', 'TypeDiagnostics'
	Type Type `json:"type,omitempty"`
}

// MarshalJSON is the custom marshaler for Suppression.
func (s Suppression) MarshalJSON() ([]byte, error) {
	s.Type = TypeSuppression
	objectMap := make(map[string]interface{})
	if s.SuppressionConfig != nil {
		objectMap["suppressionConfig"] = s.SuppressionConfig
	}
	if s.Scope != nil {
		objectMap["scope"] = s.Scope
	}
	if s.Conditions != nil {
		objectMap["conditions"] = s.Conditions
	}
	if s.Description != nil {
		objectMap["description"] = s.Description
	}
	if s.Status != "" {
		objectMap["status"] = s.Status
	}
	if s.Type != "" {
		objectMap["type"] = s.Type
	}
	return json.Marshal(objectMap)
}

// AsSuppression is the BasicActionRuleProperties implementation for Suppression.
func (s Suppression) AsSuppression() (*Suppression, bool) {
	return &s, true
}

// AsActionGroup is the BasicActionRuleProperties implementation for Suppression.
func (s Suppression) AsActionGroup() (*ActionGroup, bool) {
	return nil, false
}

// AsDiagnostics is the BasicActionRuleProperties implementation for Suppression.
func (s Suppression) AsDiagnostics() (*Diagnostics, bool) {
	return nil, false
}

// AsActionRuleProperties is the BasicActionRuleProperties implementation for Suppression.
func (s Suppression) AsActionRuleProperties() (*ActionRuleProperties, bool) {
	return nil, false
}

// AsBasicActionRuleProperties is the BasicActionRuleProperties implementation for Suppression.
func (s Suppression) AsBasicActionRuleProperties() (BasicActionRuleProperties, bool) {
	return &s, true
}

// SuppressionConfig suppression logic for a given action rule
type SuppressionConfig struct {
	// RecurrenceType - Specifies when the suppression should be applied. Possible values include: 'Always', 'Once', 'Daily', 'Weekly', 'Monthly'
	RecurrenceType SuppressionType `json:"recurrenceType,omitempty"`
	// Schedule - suppression schedule configuration
	Schedule *SuppressionSchedule `json:"schedule,omitempty"`
}

// SuppressionSchedule schedule for a given suppression configuration.
type SuppressionSchedule struct {
	// StartDate - Start date for suppression
	StartDate *string `json:"startDate,omitempty"`
	// EndDate - End date for suppression
	EndDate *string `json:"endDate,omitempty"`
	// StartTime - Start time for suppression
	StartTime *string `json:"startTime,omitempty"`
	// EndTime - End date for suppression
	EndTime *string `json:"endTime,omitempty"`
	// RecurrenceValues - Specifies the values for recurrence pattern
	RecurrenceValues *[]int32 `json:"recurrenceValues,omitempty"`
}

// ThrottlingInformation optional throttling information for the alert rule.
type ThrottlingInformation struct {
	// Duration - The required duration (in ISO8601 format) to wait before notifying on the alert rule again. The time granularity must be in minutes and minimum value is 0 minutes
	Duration *string `json:"duration,omitempty"`
}
