...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2021-05-01-preview/metrics/models.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2021-05-01-preview/metrics

     1  package metrics
     2  
     3  // Copyright (c) Microsoft Corporation. All rights reserved.
     4  // Licensed under the MIT License. See License.txt in the project root for license information.
     5  //
     6  // Code generated by Microsoft (R) AutoRest Code Generator.
     7  // Changes may cause incorrect behavior and will be lost if the code is regenerated.
     8  
     9  import (
    10  	"encoding/json"
    11  	"github.com/Azure/go-autorest/autorest"
    12  	"github.com/Azure/go-autorest/autorest/date"
    13  )
    14  
    15  // The package's fully qualified name.
    16  const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2021-05-01-preview/metrics"
    17  
    18  // AlertAction an alert action.
    19  type AlertAction struct {
    20  	// ActionGroupID - the id of the action group to use.
    21  	ActionGroupID *string `json:"actionGroupId,omitempty"`
    22  	// WebHookProperties - This field allows specifying custom properties, which would be appended to the alert payload sent as input to the webhook.
    23  	WebHookProperties map[string]*string `json:"webHookProperties"`
    24  }
    25  
    26  // MarshalJSON is the custom marshaler for AlertAction.
    27  func (aa AlertAction) MarshalJSON() ([]byte, error) {
    28  	objectMap := make(map[string]interface{})
    29  	if aa.ActionGroupID != nil {
    30  		objectMap["actionGroupId"] = aa.ActionGroupID
    31  	}
    32  	if aa.WebHookProperties != nil {
    33  		objectMap["webHookProperties"] = aa.WebHookProperties
    34  	}
    35  	return json.Marshal(objectMap)
    36  }
    37  
    38  // BasicAlertCriteria the rule criteria that defines the conditions of the alert rule.
    39  type BasicAlertCriteria interface {
    40  	AsAlertSingleResourceMultipleMetricCriteria() (*AlertSingleResourceMultipleMetricCriteria, bool)
    41  	AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool)
    42  	AsAlertMultipleResourceMultipleMetricCriteria() (*AlertMultipleResourceMultipleMetricCriteria, bool)
    43  	AsAlertCriteria() (*AlertCriteria, bool)
    44  }
    45  
    46  // AlertCriteria the rule criteria that defines the conditions of the alert rule.
    47  type AlertCriteria struct {
    48  	// AdditionalProperties - Unmatched properties from the message are deserialized this collection
    49  	AdditionalProperties map[string]interface{} `json:""`
    50  	// OdataType - Possible values include: 'OdataTypeMetricAlertCriteria', 'OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria', 'OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria', 'OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria'
    51  	OdataType OdataType `json:"odata.type,omitempty"`
    52  }
    53  
    54  func unmarshalBasicAlertCriteria(body []byte) (BasicAlertCriteria, error) {
    55  	var m map[string]interface{}
    56  	err := json.Unmarshal(body, &m)
    57  	if err != nil {
    58  		return nil, err
    59  	}
    60  
    61  	switch m["odata.type"] {
    62  	case string(OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria):
    63  		var asrmmc AlertSingleResourceMultipleMetricCriteria
    64  		err := json.Unmarshal(body, &asrmmc)
    65  		return asrmmc, err
    66  	case string(OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria):
    67  		var wlac WebtestLocationAvailabilityCriteria
    68  		err := json.Unmarshal(body, &wlac)
    69  		return wlac, err
    70  	case string(OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria):
    71  		var amrmmc AlertMultipleResourceMultipleMetricCriteria
    72  		err := json.Unmarshal(body, &amrmmc)
    73  		return amrmmc, err
    74  	default:
    75  		var ac AlertCriteria
    76  		err := json.Unmarshal(body, &ac)
    77  		return ac, err
    78  	}
    79  }
    80  func unmarshalBasicAlertCriteriaArray(body []byte) ([]BasicAlertCriteria, error) {
    81  	var rawMessages []*json.RawMessage
    82  	err := json.Unmarshal(body, &rawMessages)
    83  	if err != nil {
    84  		return nil, err
    85  	}
    86  
    87  	acArray := make([]BasicAlertCriteria, len(rawMessages))
    88  
    89  	for index, rawMessage := range rawMessages {
    90  		ac, err := unmarshalBasicAlertCriteria(*rawMessage)
    91  		if err != nil {
    92  			return nil, err
    93  		}
    94  		acArray[index] = ac
    95  	}
    96  	return acArray, nil
    97  }
    98  
    99  // MarshalJSON is the custom marshaler for AlertCriteria.
   100  func (ac AlertCriteria) MarshalJSON() ([]byte, error) {
   101  	ac.OdataType = OdataTypeMetricAlertCriteria
   102  	objectMap := make(map[string]interface{})
   103  	if ac.OdataType != "" {
   104  		objectMap["odata.type"] = ac.OdataType
   105  	}
   106  	for k, v := range ac.AdditionalProperties {
   107  		objectMap[k] = v
   108  	}
   109  	return json.Marshal(objectMap)
   110  }
   111  
   112  // AsAlertSingleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for AlertCriteria.
   113  func (ac AlertCriteria) AsAlertSingleResourceMultipleMetricCriteria() (*AlertSingleResourceMultipleMetricCriteria, bool) {
   114  	return nil, false
   115  }
   116  
   117  // AsWebtestLocationAvailabilityCriteria is the BasicAlertCriteria implementation for AlertCriteria.
   118  func (ac AlertCriteria) AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool) {
   119  	return nil, false
   120  }
   121  
   122  // AsAlertMultipleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for AlertCriteria.
   123  func (ac AlertCriteria) AsAlertMultipleResourceMultipleMetricCriteria() (*AlertMultipleResourceMultipleMetricCriteria, bool) {
   124  	return nil, false
   125  }
   126  
   127  // AsAlertCriteria is the BasicAlertCriteria implementation for AlertCriteria.
   128  func (ac AlertCriteria) AsAlertCriteria() (*AlertCriteria, bool) {
   129  	return &ac, true
   130  }
   131  
   132  // AsBasicAlertCriteria is the BasicAlertCriteria implementation for AlertCriteria.
   133  func (ac AlertCriteria) AsBasicAlertCriteria() (BasicAlertCriteria, bool) {
   134  	return &ac, true
   135  }
   136  
   137  // UnmarshalJSON is the custom unmarshaler for AlertCriteria struct.
   138  func (ac *AlertCriteria) UnmarshalJSON(body []byte) error {
   139  	var m map[string]*json.RawMessage
   140  	err := json.Unmarshal(body, &m)
   141  	if err != nil {
   142  		return err
   143  	}
   144  	for k, v := range m {
   145  		switch k {
   146  		default:
   147  			if v != nil {
   148  				var additionalProperties interface{}
   149  				err = json.Unmarshal(*v, &additionalProperties)
   150  				if err != nil {
   151  					return err
   152  				}
   153  				if ac.AdditionalProperties == nil {
   154  					ac.AdditionalProperties = make(map[string]interface{})
   155  				}
   156  				ac.AdditionalProperties[k] = additionalProperties
   157  			}
   158  		case "odata.type":
   159  			if v != nil {
   160  				var odataType OdataType
   161  				err = json.Unmarshal(*v, &odataType)
   162  				if err != nil {
   163  					return err
   164  				}
   165  				ac.OdataType = odataType
   166  			}
   167  		}
   168  	}
   169  
   170  	return nil
   171  }
   172  
   173  // AlertMultipleResourceMultipleMetricCriteria specifies the metric alert criteria for multiple resource
   174  // that has multiple metric criteria.
   175  type AlertMultipleResourceMultipleMetricCriteria struct {
   176  	// AllOf - the list of multiple metric criteria for this 'all of' operation.
   177  	AllOf *[]BasicMultiMetricCriteria `json:"allOf,omitempty"`
   178  	// AdditionalProperties - Unmatched properties from the message are deserialized this collection
   179  	AdditionalProperties map[string]interface{} `json:""`
   180  	// OdataType - Possible values include: 'OdataTypeMetricAlertCriteria', 'OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria', 'OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria', 'OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria'
   181  	OdataType OdataType `json:"odata.type,omitempty"`
   182  }
   183  
   184  // MarshalJSON is the custom marshaler for AlertMultipleResourceMultipleMetricCriteria.
   185  func (amrmmc AlertMultipleResourceMultipleMetricCriteria) MarshalJSON() ([]byte, error) {
   186  	amrmmc.OdataType = OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria
   187  	objectMap := make(map[string]interface{})
   188  	if amrmmc.AllOf != nil {
   189  		objectMap["allOf"] = amrmmc.AllOf
   190  	}
   191  	if amrmmc.OdataType != "" {
   192  		objectMap["odata.type"] = amrmmc.OdataType
   193  	}
   194  	for k, v := range amrmmc.AdditionalProperties {
   195  		objectMap[k] = v
   196  	}
   197  	return json.Marshal(objectMap)
   198  }
   199  
   200  // AsAlertSingleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for AlertMultipleResourceMultipleMetricCriteria.
   201  func (amrmmc AlertMultipleResourceMultipleMetricCriteria) AsAlertSingleResourceMultipleMetricCriteria() (*AlertSingleResourceMultipleMetricCriteria, bool) {
   202  	return nil, false
   203  }
   204  
   205  // AsWebtestLocationAvailabilityCriteria is the BasicAlertCriteria implementation for AlertMultipleResourceMultipleMetricCriteria.
   206  func (amrmmc AlertMultipleResourceMultipleMetricCriteria) AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool) {
   207  	return nil, false
   208  }
   209  
   210  // AsAlertMultipleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for AlertMultipleResourceMultipleMetricCriteria.
   211  func (amrmmc AlertMultipleResourceMultipleMetricCriteria) AsAlertMultipleResourceMultipleMetricCriteria() (*AlertMultipleResourceMultipleMetricCriteria, bool) {
   212  	return &amrmmc, true
   213  }
   214  
   215  // AsAlertCriteria is the BasicAlertCriteria implementation for AlertMultipleResourceMultipleMetricCriteria.
   216  func (amrmmc AlertMultipleResourceMultipleMetricCriteria) AsAlertCriteria() (*AlertCriteria, bool) {
   217  	return nil, false
   218  }
   219  
   220  // AsBasicAlertCriteria is the BasicAlertCriteria implementation for AlertMultipleResourceMultipleMetricCriteria.
   221  func (amrmmc AlertMultipleResourceMultipleMetricCriteria) AsBasicAlertCriteria() (BasicAlertCriteria, bool) {
   222  	return &amrmmc, true
   223  }
   224  
   225  // UnmarshalJSON is the custom unmarshaler for AlertMultipleResourceMultipleMetricCriteria struct.
   226  func (amrmmc *AlertMultipleResourceMultipleMetricCriteria) UnmarshalJSON(body []byte) error {
   227  	var m map[string]*json.RawMessage
   228  	err := json.Unmarshal(body, &m)
   229  	if err != nil {
   230  		return err
   231  	}
   232  	for k, v := range m {
   233  		switch k {
   234  		case "allOf":
   235  			if v != nil {
   236  				allOf, err := unmarshalBasicMultiMetricCriteriaArray(*v)
   237  				if err != nil {
   238  					return err
   239  				}
   240  				amrmmc.AllOf = &allOf
   241  			}
   242  		default:
   243  			if v != nil {
   244  				var additionalProperties interface{}
   245  				err = json.Unmarshal(*v, &additionalProperties)
   246  				if err != nil {
   247  					return err
   248  				}
   249  				if amrmmc.AdditionalProperties == nil {
   250  					amrmmc.AdditionalProperties = make(map[string]interface{})
   251  				}
   252  				amrmmc.AdditionalProperties[k] = additionalProperties
   253  			}
   254  		case "odata.type":
   255  			if v != nil {
   256  				var odataType OdataType
   257  				err = json.Unmarshal(*v, &odataType)
   258  				if err != nil {
   259  					return err
   260  				}
   261  				amrmmc.OdataType = odataType
   262  			}
   263  		}
   264  	}
   265  
   266  	return nil
   267  }
   268  
   269  // AlertProperties an alert rule.
   270  type AlertProperties struct {
   271  	// Description - the description of the metric alert that will be included in the alert email.
   272  	Description *string `json:"description,omitempty"`
   273  	// Severity - Alert severity {0, 1, 2, 3, 4}
   274  	Severity *int32 `json:"severity,omitempty"`
   275  	// Enabled - the flag that indicates whether the metric alert is enabled.
   276  	Enabled *bool `json:"enabled,omitempty"`
   277  	// Scopes - the list of resource id's that this metric alert is scoped to.
   278  	Scopes *[]string `json:"scopes,omitempty"`
   279  	// EvaluationFrequency - how often the metric alert is evaluated represented in ISO 8601 duration format.
   280  	EvaluationFrequency *string `json:"evaluationFrequency,omitempty"`
   281  	// WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold.
   282  	WindowSize *string `json:"windowSize,omitempty"`
   283  	// TargetResourceType - the resource type of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource.
   284  	TargetResourceType *string `json:"targetResourceType,omitempty"`
   285  	// TargetResourceRegion - the region of the target resource(s) on which the alert is created/updated. Mandatory if the scope contains a subscription, resource group, or more than one resource.
   286  	TargetResourceRegion *string `json:"targetResourceRegion,omitempty"`
   287  	// Criteria - defines the specific alert criteria information.
   288  	Criteria BasicAlertCriteria `json:"criteria,omitempty"`
   289  	// AutoMitigate - the flag that indicates whether the alert should be auto resolved or not. The default is true.
   290  	AutoMitigate *bool `json:"autoMitigate,omitempty"`
   291  	// Actions - the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved.
   292  	Actions *[]AlertAction `json:"actions,omitempty"`
   293  	// LastUpdatedTime - READ-ONLY; Last time the rule was updated in ISO8601 format.
   294  	LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"`
   295  	// IsMigrated - READ-ONLY; the value indicating whether this alert rule is migrated.
   296  	IsMigrated *bool `json:"isMigrated,omitempty"`
   297  }
   298  
   299  // MarshalJSON is the custom marshaler for AlertProperties.
   300  func (ap AlertProperties) MarshalJSON() ([]byte, error) {
   301  	objectMap := make(map[string]interface{})
   302  	if ap.Description != nil {
   303  		objectMap["description"] = ap.Description
   304  	}
   305  	if ap.Severity != nil {
   306  		objectMap["severity"] = ap.Severity
   307  	}
   308  	if ap.Enabled != nil {
   309  		objectMap["enabled"] = ap.Enabled
   310  	}
   311  	if ap.Scopes != nil {
   312  		objectMap["scopes"] = ap.Scopes
   313  	}
   314  	if ap.EvaluationFrequency != nil {
   315  		objectMap["evaluationFrequency"] = ap.EvaluationFrequency
   316  	}
   317  	if ap.WindowSize != nil {
   318  		objectMap["windowSize"] = ap.WindowSize
   319  	}
   320  	if ap.TargetResourceType != nil {
   321  		objectMap["targetResourceType"] = ap.TargetResourceType
   322  	}
   323  	if ap.TargetResourceRegion != nil {
   324  		objectMap["targetResourceRegion"] = ap.TargetResourceRegion
   325  	}
   326  	objectMap["criteria"] = ap.Criteria
   327  	if ap.AutoMitigate != nil {
   328  		objectMap["autoMitigate"] = ap.AutoMitigate
   329  	}
   330  	if ap.Actions != nil {
   331  		objectMap["actions"] = ap.Actions
   332  	}
   333  	return json.Marshal(objectMap)
   334  }
   335  
   336  // UnmarshalJSON is the custom unmarshaler for AlertProperties struct.
   337  func (ap *AlertProperties) UnmarshalJSON(body []byte) error {
   338  	var m map[string]*json.RawMessage
   339  	err := json.Unmarshal(body, &m)
   340  	if err != nil {
   341  		return err
   342  	}
   343  	for k, v := range m {
   344  		switch k {
   345  		case "description":
   346  			if v != nil {
   347  				var description string
   348  				err = json.Unmarshal(*v, &description)
   349  				if err != nil {
   350  					return err
   351  				}
   352  				ap.Description = &description
   353  			}
   354  		case "severity":
   355  			if v != nil {
   356  				var severity int32
   357  				err = json.Unmarshal(*v, &severity)
   358  				if err != nil {
   359  					return err
   360  				}
   361  				ap.Severity = &severity
   362  			}
   363  		case "enabled":
   364  			if v != nil {
   365  				var enabled bool
   366  				err = json.Unmarshal(*v, &enabled)
   367  				if err != nil {
   368  					return err
   369  				}
   370  				ap.Enabled = &enabled
   371  			}
   372  		case "scopes":
   373  			if v != nil {
   374  				var scopes []string
   375  				err = json.Unmarshal(*v, &scopes)
   376  				if err != nil {
   377  					return err
   378  				}
   379  				ap.Scopes = &scopes
   380  			}
   381  		case "evaluationFrequency":
   382  			if v != nil {
   383  				var evaluationFrequency string
   384  				err = json.Unmarshal(*v, &evaluationFrequency)
   385  				if err != nil {
   386  					return err
   387  				}
   388  				ap.EvaluationFrequency = &evaluationFrequency
   389  			}
   390  		case "windowSize":
   391  			if v != nil {
   392  				var windowSize string
   393  				err = json.Unmarshal(*v, &windowSize)
   394  				if err != nil {
   395  					return err
   396  				}
   397  				ap.WindowSize = &windowSize
   398  			}
   399  		case "targetResourceType":
   400  			if v != nil {
   401  				var targetResourceType string
   402  				err = json.Unmarshal(*v, &targetResourceType)
   403  				if err != nil {
   404  					return err
   405  				}
   406  				ap.TargetResourceType = &targetResourceType
   407  			}
   408  		case "targetResourceRegion":
   409  			if v != nil {
   410  				var targetResourceRegion string
   411  				err = json.Unmarshal(*v, &targetResourceRegion)
   412  				if err != nil {
   413  					return err
   414  				}
   415  				ap.TargetResourceRegion = &targetResourceRegion
   416  			}
   417  		case "criteria":
   418  			if v != nil {
   419  				criteria, err := unmarshalBasicAlertCriteria(*v)
   420  				if err != nil {
   421  					return err
   422  				}
   423  				ap.Criteria = criteria
   424  			}
   425  		case "autoMitigate":
   426  			if v != nil {
   427  				var autoMitigate bool
   428  				err = json.Unmarshal(*v, &autoMitigate)
   429  				if err != nil {
   430  					return err
   431  				}
   432  				ap.AutoMitigate = &autoMitigate
   433  			}
   434  		case "actions":
   435  			if v != nil {
   436  				var actions []AlertAction
   437  				err = json.Unmarshal(*v, &actions)
   438  				if err != nil {
   439  					return err
   440  				}
   441  				ap.Actions = &actions
   442  			}
   443  		case "lastUpdatedTime":
   444  			if v != nil {
   445  				var lastUpdatedTime date.Time
   446  				err = json.Unmarshal(*v, &lastUpdatedTime)
   447  				if err != nil {
   448  					return err
   449  				}
   450  				ap.LastUpdatedTime = &lastUpdatedTime
   451  			}
   452  		case "isMigrated":
   453  			if v != nil {
   454  				var isMigrated bool
   455  				err = json.Unmarshal(*v, &isMigrated)
   456  				if err != nil {
   457  					return err
   458  				}
   459  				ap.IsMigrated = &isMigrated
   460  			}
   461  		}
   462  	}
   463  
   464  	return nil
   465  }
   466  
   467  // AlertPropertiesPatch an alert rule properties for patch.
   468  type AlertPropertiesPatch struct {
   469  	// Description - the description of the metric alert that will be included in the alert email.
   470  	Description *string `json:"description,omitempty"`
   471  	// Severity - Alert severity {0, 1, 2, 3, 4}
   472  	Severity *int32 `json:"severity,omitempty"`
   473  	// Enabled - the flag that indicates whether the metric alert is enabled.
   474  	Enabled *bool `json:"enabled,omitempty"`
   475  	// Scopes - the list of resource id's that this metric alert is scoped to.
   476  	Scopes *[]string `json:"scopes,omitempty"`
   477  	// EvaluationFrequency - how often the metric alert is evaluated represented in ISO 8601 duration format.
   478  	EvaluationFrequency *string `json:"evaluationFrequency,omitempty"`
   479  	// WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold.
   480  	WindowSize *string `json:"windowSize,omitempty"`
   481  	// TargetResourceType - the resource type of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria.
   482  	TargetResourceType *string `json:"targetResourceType,omitempty"`
   483  	// TargetResourceRegion - the region of the target resource(s) on which the alert is created/updated. Mandatory for MultipleResourceMultipleMetricCriteria.
   484  	TargetResourceRegion *string `json:"targetResourceRegion,omitempty"`
   485  	// Criteria - defines the specific alert criteria information.
   486  	Criteria BasicAlertCriteria `json:"criteria,omitempty"`
   487  	// AutoMitigate - the flag that indicates whether the alert should be auto resolved or not. The default is true.
   488  	AutoMitigate *bool `json:"autoMitigate,omitempty"`
   489  	// Actions - the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved.
   490  	Actions *[]AlertAction `json:"actions,omitempty"`
   491  	// LastUpdatedTime - READ-ONLY; Last time the rule was updated in ISO8601 format.
   492  	LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"`
   493  	// IsMigrated - READ-ONLY; the value indicating whether this alert rule is migrated.
   494  	IsMigrated *bool `json:"isMigrated,omitempty"`
   495  }
   496  
   497  // MarshalJSON is the custom marshaler for AlertPropertiesPatch.
   498  func (app AlertPropertiesPatch) MarshalJSON() ([]byte, error) {
   499  	objectMap := make(map[string]interface{})
   500  	if app.Description != nil {
   501  		objectMap["description"] = app.Description
   502  	}
   503  	if app.Severity != nil {
   504  		objectMap["severity"] = app.Severity
   505  	}
   506  	if app.Enabled != nil {
   507  		objectMap["enabled"] = app.Enabled
   508  	}
   509  	if app.Scopes != nil {
   510  		objectMap["scopes"] = app.Scopes
   511  	}
   512  	if app.EvaluationFrequency != nil {
   513  		objectMap["evaluationFrequency"] = app.EvaluationFrequency
   514  	}
   515  	if app.WindowSize != nil {
   516  		objectMap["windowSize"] = app.WindowSize
   517  	}
   518  	if app.TargetResourceType != nil {
   519  		objectMap["targetResourceType"] = app.TargetResourceType
   520  	}
   521  	if app.TargetResourceRegion != nil {
   522  		objectMap["targetResourceRegion"] = app.TargetResourceRegion
   523  	}
   524  	objectMap["criteria"] = app.Criteria
   525  	if app.AutoMitigate != nil {
   526  		objectMap["autoMitigate"] = app.AutoMitigate
   527  	}
   528  	if app.Actions != nil {
   529  		objectMap["actions"] = app.Actions
   530  	}
   531  	return json.Marshal(objectMap)
   532  }
   533  
   534  // UnmarshalJSON is the custom unmarshaler for AlertPropertiesPatch struct.
   535  func (app *AlertPropertiesPatch) UnmarshalJSON(body []byte) error {
   536  	var m map[string]*json.RawMessage
   537  	err := json.Unmarshal(body, &m)
   538  	if err != nil {
   539  		return err
   540  	}
   541  	for k, v := range m {
   542  		switch k {
   543  		case "description":
   544  			if v != nil {
   545  				var description string
   546  				err = json.Unmarshal(*v, &description)
   547  				if err != nil {
   548  					return err
   549  				}
   550  				app.Description = &description
   551  			}
   552  		case "severity":
   553  			if v != nil {
   554  				var severity int32
   555  				err = json.Unmarshal(*v, &severity)
   556  				if err != nil {
   557  					return err
   558  				}
   559  				app.Severity = &severity
   560  			}
   561  		case "enabled":
   562  			if v != nil {
   563  				var enabled bool
   564  				err = json.Unmarshal(*v, &enabled)
   565  				if err != nil {
   566  					return err
   567  				}
   568  				app.Enabled = &enabled
   569  			}
   570  		case "scopes":
   571  			if v != nil {
   572  				var scopes []string
   573  				err = json.Unmarshal(*v, &scopes)
   574  				if err != nil {
   575  					return err
   576  				}
   577  				app.Scopes = &scopes
   578  			}
   579  		case "evaluationFrequency":
   580  			if v != nil {
   581  				var evaluationFrequency string
   582  				err = json.Unmarshal(*v, &evaluationFrequency)
   583  				if err != nil {
   584  					return err
   585  				}
   586  				app.EvaluationFrequency = &evaluationFrequency
   587  			}
   588  		case "windowSize":
   589  			if v != nil {
   590  				var windowSize string
   591  				err = json.Unmarshal(*v, &windowSize)
   592  				if err != nil {
   593  					return err
   594  				}
   595  				app.WindowSize = &windowSize
   596  			}
   597  		case "targetResourceType":
   598  			if v != nil {
   599  				var targetResourceType string
   600  				err = json.Unmarshal(*v, &targetResourceType)
   601  				if err != nil {
   602  					return err
   603  				}
   604  				app.TargetResourceType = &targetResourceType
   605  			}
   606  		case "targetResourceRegion":
   607  			if v != nil {
   608  				var targetResourceRegion string
   609  				err = json.Unmarshal(*v, &targetResourceRegion)
   610  				if err != nil {
   611  					return err
   612  				}
   613  				app.TargetResourceRegion = &targetResourceRegion
   614  			}
   615  		case "criteria":
   616  			if v != nil {
   617  				criteria, err := unmarshalBasicAlertCriteria(*v)
   618  				if err != nil {
   619  					return err
   620  				}
   621  				app.Criteria = criteria
   622  			}
   623  		case "autoMitigate":
   624  			if v != nil {
   625  				var autoMitigate bool
   626  				err = json.Unmarshal(*v, &autoMitigate)
   627  				if err != nil {
   628  					return err
   629  				}
   630  				app.AutoMitigate = &autoMitigate
   631  			}
   632  		case "actions":
   633  			if v != nil {
   634  				var actions []AlertAction
   635  				err = json.Unmarshal(*v, &actions)
   636  				if err != nil {
   637  					return err
   638  				}
   639  				app.Actions = &actions
   640  			}
   641  		case "lastUpdatedTime":
   642  			if v != nil {
   643  				var lastUpdatedTime date.Time
   644  				err = json.Unmarshal(*v, &lastUpdatedTime)
   645  				if err != nil {
   646  					return err
   647  				}
   648  				app.LastUpdatedTime = &lastUpdatedTime
   649  			}
   650  		case "isMigrated":
   651  			if v != nil {
   652  				var isMigrated bool
   653  				err = json.Unmarshal(*v, &isMigrated)
   654  				if err != nil {
   655  					return err
   656  				}
   657  				app.IsMigrated = &isMigrated
   658  			}
   659  		}
   660  	}
   661  
   662  	return nil
   663  }
   664  
   665  // AlertResource the metric alert resource.
   666  type AlertResource struct {
   667  	autorest.Response `json:"-"`
   668  	// AlertProperties - The alert rule properties of the resource.
   669  	*AlertProperties `json:"properties,omitempty"`
   670  	// ID - READ-ONLY; Azure resource Id
   671  	ID *string `json:"id,omitempty"`
   672  	// Name - READ-ONLY; Azure resource name
   673  	Name *string `json:"name,omitempty"`
   674  	// Type - READ-ONLY; Azure resource type
   675  	Type *string `json:"type,omitempty"`
   676  	// Location - Resource location
   677  	Location *string `json:"location,omitempty"`
   678  	// Tags - Resource tags
   679  	Tags map[string]*string `json:"tags"`
   680  }
   681  
   682  // MarshalJSON is the custom marshaler for AlertResource.
   683  func (ar AlertResource) MarshalJSON() ([]byte, error) {
   684  	objectMap := make(map[string]interface{})
   685  	if ar.AlertProperties != nil {
   686  		objectMap["properties"] = ar.AlertProperties
   687  	}
   688  	if ar.Location != nil {
   689  		objectMap["location"] = ar.Location
   690  	}
   691  	if ar.Tags != nil {
   692  		objectMap["tags"] = ar.Tags
   693  	}
   694  	return json.Marshal(objectMap)
   695  }
   696  
   697  // UnmarshalJSON is the custom unmarshaler for AlertResource struct.
   698  func (ar *AlertResource) UnmarshalJSON(body []byte) error {
   699  	var m map[string]*json.RawMessage
   700  	err := json.Unmarshal(body, &m)
   701  	if err != nil {
   702  		return err
   703  	}
   704  	for k, v := range m {
   705  		switch k {
   706  		case "properties":
   707  			if v != nil {
   708  				var alertProperties AlertProperties
   709  				err = json.Unmarshal(*v, &alertProperties)
   710  				if err != nil {
   711  					return err
   712  				}
   713  				ar.AlertProperties = &alertProperties
   714  			}
   715  		case "id":
   716  			if v != nil {
   717  				var ID string
   718  				err = json.Unmarshal(*v, &ID)
   719  				if err != nil {
   720  					return err
   721  				}
   722  				ar.ID = &ID
   723  			}
   724  		case "name":
   725  			if v != nil {
   726  				var name string
   727  				err = json.Unmarshal(*v, &name)
   728  				if err != nil {
   729  					return err
   730  				}
   731  				ar.Name = &name
   732  			}
   733  		case "type":
   734  			if v != nil {
   735  				var typeVar string
   736  				err = json.Unmarshal(*v, &typeVar)
   737  				if err != nil {
   738  					return err
   739  				}
   740  				ar.Type = &typeVar
   741  			}
   742  		case "location":
   743  			if v != nil {
   744  				var location string
   745  				err = json.Unmarshal(*v, &location)
   746  				if err != nil {
   747  					return err
   748  				}
   749  				ar.Location = &location
   750  			}
   751  		case "tags":
   752  			if v != nil {
   753  				var tags map[string]*string
   754  				err = json.Unmarshal(*v, &tags)
   755  				if err != nil {
   756  					return err
   757  				}
   758  				ar.Tags = tags
   759  			}
   760  		}
   761  	}
   762  
   763  	return nil
   764  }
   765  
   766  // AlertResourceCollection represents a collection of alert rule resources.
   767  type AlertResourceCollection struct {
   768  	autorest.Response `json:"-"`
   769  	// Value - the values for the alert rule resources.
   770  	Value *[]AlertResource `json:"value,omitempty"`
   771  }
   772  
   773  // AlertResourcePatch the metric alert resource for patch operations.
   774  type AlertResourcePatch struct {
   775  	// Tags - Resource tags
   776  	Tags map[string]*string `json:"tags"`
   777  	// AlertPropertiesPatch - The alert rule properties of the resource.
   778  	*AlertPropertiesPatch `json:"properties,omitempty"`
   779  }
   780  
   781  // MarshalJSON is the custom marshaler for AlertResourcePatch.
   782  func (arp AlertResourcePatch) MarshalJSON() ([]byte, error) {
   783  	objectMap := make(map[string]interface{})
   784  	if arp.Tags != nil {
   785  		objectMap["tags"] = arp.Tags
   786  	}
   787  	if arp.AlertPropertiesPatch != nil {
   788  		objectMap["properties"] = arp.AlertPropertiesPatch
   789  	}
   790  	return json.Marshal(objectMap)
   791  }
   792  
   793  // UnmarshalJSON is the custom unmarshaler for AlertResourcePatch struct.
   794  func (arp *AlertResourcePatch) UnmarshalJSON(body []byte) error {
   795  	var m map[string]*json.RawMessage
   796  	err := json.Unmarshal(body, &m)
   797  	if err != nil {
   798  		return err
   799  	}
   800  	for k, v := range m {
   801  		switch k {
   802  		case "tags":
   803  			if v != nil {
   804  				var tags map[string]*string
   805  				err = json.Unmarshal(*v, &tags)
   806  				if err != nil {
   807  					return err
   808  				}
   809  				arp.Tags = tags
   810  			}
   811  		case "properties":
   812  			if v != nil {
   813  				var alertPropertiesPatch AlertPropertiesPatch
   814  				err = json.Unmarshal(*v, &alertPropertiesPatch)
   815  				if err != nil {
   816  					return err
   817  				}
   818  				arp.AlertPropertiesPatch = &alertPropertiesPatch
   819  			}
   820  		}
   821  	}
   822  
   823  	return nil
   824  }
   825  
   826  // AlertSingleResourceMultipleMetricCriteria specifies the metric alert criteria for a single resource that
   827  // has multiple metric criteria.
   828  type AlertSingleResourceMultipleMetricCriteria struct {
   829  	// AllOf - The list of metric criteria for this 'all of' operation.
   830  	AllOf *[]Criteria `json:"allOf,omitempty"`
   831  	// AdditionalProperties - Unmatched properties from the message are deserialized this collection
   832  	AdditionalProperties map[string]interface{} `json:""`
   833  	// OdataType - Possible values include: 'OdataTypeMetricAlertCriteria', 'OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria', 'OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria', 'OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria'
   834  	OdataType OdataType `json:"odata.type,omitempty"`
   835  }
   836  
   837  // MarshalJSON is the custom marshaler for AlertSingleResourceMultipleMetricCriteria.
   838  func (asrmmc AlertSingleResourceMultipleMetricCriteria) MarshalJSON() ([]byte, error) {
   839  	asrmmc.OdataType = OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria
   840  	objectMap := make(map[string]interface{})
   841  	if asrmmc.AllOf != nil {
   842  		objectMap["allOf"] = asrmmc.AllOf
   843  	}
   844  	if asrmmc.OdataType != "" {
   845  		objectMap["odata.type"] = asrmmc.OdataType
   846  	}
   847  	for k, v := range asrmmc.AdditionalProperties {
   848  		objectMap[k] = v
   849  	}
   850  	return json.Marshal(objectMap)
   851  }
   852  
   853  // AsAlertSingleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for AlertSingleResourceMultipleMetricCriteria.
   854  func (asrmmc AlertSingleResourceMultipleMetricCriteria) AsAlertSingleResourceMultipleMetricCriteria() (*AlertSingleResourceMultipleMetricCriteria, bool) {
   855  	return &asrmmc, true
   856  }
   857  
   858  // AsWebtestLocationAvailabilityCriteria is the BasicAlertCriteria implementation for AlertSingleResourceMultipleMetricCriteria.
   859  func (asrmmc AlertSingleResourceMultipleMetricCriteria) AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool) {
   860  	return nil, false
   861  }
   862  
   863  // AsAlertMultipleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for AlertSingleResourceMultipleMetricCriteria.
   864  func (asrmmc AlertSingleResourceMultipleMetricCriteria) AsAlertMultipleResourceMultipleMetricCriteria() (*AlertMultipleResourceMultipleMetricCriteria, bool) {
   865  	return nil, false
   866  }
   867  
   868  // AsAlertCriteria is the BasicAlertCriteria implementation for AlertSingleResourceMultipleMetricCriteria.
   869  func (asrmmc AlertSingleResourceMultipleMetricCriteria) AsAlertCriteria() (*AlertCriteria, bool) {
   870  	return nil, false
   871  }
   872  
   873  // AsBasicAlertCriteria is the BasicAlertCriteria implementation for AlertSingleResourceMultipleMetricCriteria.
   874  func (asrmmc AlertSingleResourceMultipleMetricCriteria) AsBasicAlertCriteria() (BasicAlertCriteria, bool) {
   875  	return &asrmmc, true
   876  }
   877  
   878  // UnmarshalJSON is the custom unmarshaler for AlertSingleResourceMultipleMetricCriteria struct.
   879  func (asrmmc *AlertSingleResourceMultipleMetricCriteria) UnmarshalJSON(body []byte) error {
   880  	var m map[string]*json.RawMessage
   881  	err := json.Unmarshal(body, &m)
   882  	if err != nil {
   883  		return err
   884  	}
   885  	for k, v := range m {
   886  		switch k {
   887  		case "allOf":
   888  			if v != nil {
   889  				var allOf []Criteria
   890  				err = json.Unmarshal(*v, &allOf)
   891  				if err != nil {
   892  					return err
   893  				}
   894  				asrmmc.AllOf = &allOf
   895  			}
   896  		default:
   897  			if v != nil {
   898  				var additionalProperties interface{}
   899  				err = json.Unmarshal(*v, &additionalProperties)
   900  				if err != nil {
   901  					return err
   902  				}
   903  				if asrmmc.AdditionalProperties == nil {
   904  					asrmmc.AdditionalProperties = make(map[string]interface{})
   905  				}
   906  				asrmmc.AdditionalProperties[k] = additionalProperties
   907  			}
   908  		case "odata.type":
   909  			if v != nil {
   910  				var odataType OdataType
   911  				err = json.Unmarshal(*v, &odataType)
   912  				if err != nil {
   913  					return err
   914  				}
   915  				asrmmc.OdataType = odataType
   916  			}
   917  		}
   918  	}
   919  
   920  	return nil
   921  }
   922  
   923  // AlertStatus an alert status.
   924  type AlertStatus struct {
   925  	// Name - The status name.
   926  	Name *string `json:"name,omitempty"`
   927  	// ID - The alert rule arm id.
   928  	ID *string `json:"id,omitempty"`
   929  	// Type - The extended resource type name.
   930  	Type *string `json:"type,omitempty"`
   931  	// Properties - The alert status properties of the metric alert status.
   932  	Properties *AlertStatusProperties `json:"properties,omitempty"`
   933  }
   934  
   935  // AlertStatusCollection represents a collection of alert rule resources.
   936  type AlertStatusCollection struct {
   937  	autorest.Response `json:"-"`
   938  	// Value - the values for the alert rule resources.
   939  	Value *[]AlertStatus `json:"value,omitempty"`
   940  }
   941  
   942  // AlertStatusProperties an alert status properties.
   943  type AlertStatusProperties struct {
   944  	// Dimensions - An object describing the type of the dimensions.
   945  	Dimensions map[string]*string `json:"dimensions"`
   946  	// Status - status value
   947  	Status *string `json:"status,omitempty"`
   948  	// Timestamp - UTC time when the status was checked.
   949  	Timestamp *date.Time `json:"timestamp,omitempty"`
   950  }
   951  
   952  // MarshalJSON is the custom marshaler for AlertStatusProperties.
   953  func (asp AlertStatusProperties) MarshalJSON() ([]byte, error) {
   954  	objectMap := make(map[string]interface{})
   955  	if asp.Dimensions != nil {
   956  		objectMap["dimensions"] = asp.Dimensions
   957  	}
   958  	if asp.Status != nil {
   959  		objectMap["status"] = asp.Status
   960  	}
   961  	if asp.Timestamp != nil {
   962  		objectMap["timestamp"] = asp.Timestamp
   963  	}
   964  	return json.Marshal(objectMap)
   965  }
   966  
   967  // Availability metric availability specifies the time grain (aggregation interval or frequency) and the
   968  // retention period for that time grain.
   969  type Availability struct {
   970  	// TimeGrain - the time grain specifies the aggregation interval for the metric. Expressed as a duration 'PT1M', 'P1D', etc.
   971  	TimeGrain *string `json:"timeGrain,omitempty"`
   972  	// Retention - the retention period for the metric at the specified timegrain.  Expressed as a duration 'PT1M', 'P1D', etc.
   973  	Retention *string `json:"retention,omitempty"`
   974  }
   975  
   976  // BaselineMetadata represents a baseline metadata value.
   977  type BaselineMetadata struct {
   978  	// Name - Name of the baseline metadata.
   979  	Name *string `json:"name,omitempty"`
   980  	// Value - Value of the baseline metadata.
   981  	Value *string `json:"value,omitempty"`
   982  }
   983  
   984  // BaselinesProperties the response to a metric baselines query.
   985  type BaselinesProperties struct {
   986  	// Timespan - The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'.  This may be adjusted in the future and returned back from what was originally requested.
   987  	Timespan *string `json:"timespan,omitempty"`
   988  	// Interval - The interval (window size) for which the metric data was returned in.  This may be adjusted in the future and returned back from what was originally requested.  This is not present if a metadata request was made.
   989  	Interval *string `json:"interval,omitempty"`
   990  	// Namespace - The namespace of the metrics been queried.
   991  	Namespace *string `json:"namespace,omitempty"`
   992  	// Baselines - The baseline for each time series that was queried.
   993  	Baselines *[]TimeSeriesBaseline `json:"baselines,omitempty"`
   994  }
   995  
   996  // BaselinesResponse a list of metric baselines.
   997  type BaselinesResponse struct {
   998  	autorest.Response `json:"-"`
   999  	// Value - The list of metric baselines.
  1000  	Value *[]SingleMetricBaseline `json:"value,omitempty"`
  1001  }
  1002  
  1003  // Criteria criterion to filter metrics.
  1004  type Criteria struct {
  1005  	// Operator - the criteria operator. Possible values include: 'OperatorEquals', 'OperatorGreaterThan', 'OperatorGreaterThanOrEqual', 'OperatorLessThan', 'OperatorLessThanOrEqual'
  1006  	Operator Operator `json:"operator,omitempty"`
  1007  	// Threshold - the criteria threshold value that activates the alert.
  1008  	Threshold *float64 `json:"threshold,omitempty"`
  1009  	// AdditionalProperties - Unmatched properties from the message are deserialized this collection
  1010  	AdditionalProperties map[string]interface{} `json:""`
  1011  	// Name - Name of the criteria.
  1012  	Name *string `json:"name,omitempty"`
  1013  	// MetricName - Name of the metric.
  1014  	MetricName *string `json:"metricName,omitempty"`
  1015  	// MetricNamespace - Namespace of the metric.
  1016  	MetricNamespace *string `json:"metricNamespace,omitempty"`
  1017  	// TimeAggregation - the criteria time aggregation types. Possible values include: 'AggregationTypeEnumAverage', 'AggregationTypeEnumCount', 'AggregationTypeEnumMinimum', 'AggregationTypeEnumMaximum', 'AggregationTypeEnumTotal'
  1018  	TimeAggregation AggregationTypeEnum `json:"timeAggregation,omitempty"`
  1019  	// Dimensions - List of dimension conditions.
  1020  	Dimensions *[]Dimension `json:"dimensions,omitempty"`
  1021  	// SkipMetricValidation - Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped.
  1022  	SkipMetricValidation *bool `json:"skipMetricValidation,omitempty"`
  1023  	// CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion'
  1024  	CriterionType CriterionType `json:"criterionType,omitempty"`
  1025  }
  1026  
  1027  // MarshalJSON is the custom marshaler for Criteria.
  1028  func (c Criteria) MarshalJSON() ([]byte, error) {
  1029  	c.CriterionType = CriterionTypeStaticThresholdCriterion
  1030  	objectMap := make(map[string]interface{})
  1031  	if c.Operator != "" {
  1032  		objectMap["operator"] = c.Operator
  1033  	}
  1034  	if c.Threshold != nil {
  1035  		objectMap["threshold"] = c.Threshold
  1036  	}
  1037  	if c.Name != nil {
  1038  		objectMap["name"] = c.Name
  1039  	}
  1040  	if c.MetricName != nil {
  1041  		objectMap["metricName"] = c.MetricName
  1042  	}
  1043  	if c.MetricNamespace != nil {
  1044  		objectMap["metricNamespace"] = c.MetricNamespace
  1045  	}
  1046  	if c.TimeAggregation != "" {
  1047  		objectMap["timeAggregation"] = c.TimeAggregation
  1048  	}
  1049  	if c.Dimensions != nil {
  1050  		objectMap["dimensions"] = c.Dimensions
  1051  	}
  1052  	if c.SkipMetricValidation != nil {
  1053  		objectMap["skipMetricValidation"] = c.SkipMetricValidation
  1054  	}
  1055  	if c.CriterionType != "" {
  1056  		objectMap["criterionType"] = c.CriterionType
  1057  	}
  1058  	for k, v := range c.AdditionalProperties {
  1059  		objectMap[k] = v
  1060  	}
  1061  	return json.Marshal(objectMap)
  1062  }
  1063  
  1064  // AsCriteria is the BasicMultiMetricCriteria implementation for Criteria.
  1065  func (c Criteria) AsCriteria() (*Criteria, bool) {
  1066  	return &c, true
  1067  }
  1068  
  1069  // AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for Criteria.
  1070  func (c Criteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) {
  1071  	return nil, false
  1072  }
  1073  
  1074  // AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for Criteria.
  1075  func (c Criteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) {
  1076  	return nil, false
  1077  }
  1078  
  1079  // AsBasicMultiMetricCriteria is the BasicMultiMetricCriteria implementation for Criteria.
  1080  func (c Criteria) AsBasicMultiMetricCriteria() (BasicMultiMetricCriteria, bool) {
  1081  	return &c, true
  1082  }
  1083  
  1084  // UnmarshalJSON is the custom unmarshaler for Criteria struct.
  1085  func (c *Criteria) UnmarshalJSON(body []byte) error {
  1086  	var m map[string]*json.RawMessage
  1087  	err := json.Unmarshal(body, &m)
  1088  	if err != nil {
  1089  		return err
  1090  	}
  1091  	for k, v := range m {
  1092  		switch k {
  1093  		case "operator":
  1094  			if v != nil {
  1095  				var operator Operator
  1096  				err = json.Unmarshal(*v, &operator)
  1097  				if err != nil {
  1098  					return err
  1099  				}
  1100  				c.Operator = operator
  1101  			}
  1102  		case "threshold":
  1103  			if v != nil {
  1104  				var threshold float64
  1105  				err = json.Unmarshal(*v, &threshold)
  1106  				if err != nil {
  1107  					return err
  1108  				}
  1109  				c.Threshold = &threshold
  1110  			}
  1111  		default:
  1112  			if v != nil {
  1113  				var additionalProperties interface{}
  1114  				err = json.Unmarshal(*v, &additionalProperties)
  1115  				if err != nil {
  1116  					return err
  1117  				}
  1118  				if c.AdditionalProperties == nil {
  1119  					c.AdditionalProperties = make(map[string]interface{})
  1120  				}
  1121  				c.AdditionalProperties[k] = additionalProperties
  1122  			}
  1123  		case "name":
  1124  			if v != nil {
  1125  				var name string
  1126  				err = json.Unmarshal(*v, &name)
  1127  				if err != nil {
  1128  					return err
  1129  				}
  1130  				c.Name = &name
  1131  			}
  1132  		case "metricName":
  1133  			if v != nil {
  1134  				var metricName string
  1135  				err = json.Unmarshal(*v, &metricName)
  1136  				if err != nil {
  1137  					return err
  1138  				}
  1139  				c.MetricName = &metricName
  1140  			}
  1141  		case "metricNamespace":
  1142  			if v != nil {
  1143  				var metricNamespace string
  1144  				err = json.Unmarshal(*v, &metricNamespace)
  1145  				if err != nil {
  1146  					return err
  1147  				}
  1148  				c.MetricNamespace = &metricNamespace
  1149  			}
  1150  		case "timeAggregation":
  1151  			if v != nil {
  1152  				var timeAggregation AggregationTypeEnum
  1153  				err = json.Unmarshal(*v, &timeAggregation)
  1154  				if err != nil {
  1155  					return err
  1156  				}
  1157  				c.TimeAggregation = timeAggregation
  1158  			}
  1159  		case "dimensions":
  1160  			if v != nil {
  1161  				var dimensions []Dimension
  1162  				err = json.Unmarshal(*v, &dimensions)
  1163  				if err != nil {
  1164  					return err
  1165  				}
  1166  				c.Dimensions = &dimensions
  1167  			}
  1168  		case "skipMetricValidation":
  1169  			if v != nil {
  1170  				var skipMetricValidation bool
  1171  				err = json.Unmarshal(*v, &skipMetricValidation)
  1172  				if err != nil {
  1173  					return err
  1174  				}
  1175  				c.SkipMetricValidation = &skipMetricValidation
  1176  			}
  1177  		case "criterionType":
  1178  			if v != nil {
  1179  				var criterionType CriterionType
  1180  				err = json.Unmarshal(*v, &criterionType)
  1181  				if err != nil {
  1182  					return err
  1183  				}
  1184  				c.CriterionType = criterionType
  1185  			}
  1186  		}
  1187  	}
  1188  
  1189  	return nil
  1190  }
  1191  
  1192  // Definition metric definition class specifies the metadata for a metric.
  1193  type Definition struct {
  1194  	// IsDimensionRequired - Flag to indicate whether the dimension is required.
  1195  	IsDimensionRequired *bool `json:"isDimensionRequired,omitempty"`
  1196  	// ResourceID - the resource identifier of the resource that emitted the metric.
  1197  	ResourceID *string `json:"resourceId,omitempty"`
  1198  	// Namespace - the namespace the metric belongs to.
  1199  	Namespace *string `json:"namespace,omitempty"`
  1200  	// Name - the name and the display name of the metric, i.e. it is a localizable string.
  1201  	Name *LocalizableString `json:"name,omitempty"`
  1202  	// DisplayDescription - Detailed description of this metric.
  1203  	DisplayDescription *string `json:"displayDescription,omitempty"`
  1204  	// Category - Custom category name for this metric.
  1205  	Category *string `json:"category,omitempty"`
  1206  	// MetricClass - The class of the metric. Possible values include: 'MetricClassAvailability', 'MetricClassTransactions', 'MetricClassErrors', 'MetricClassLatency', 'MetricClassSaturation'
  1207  	MetricClass MetricClass `json:"metricClass,omitempty"`
  1208  	// Unit - the unit of the metric. Possible values include: 'MetricUnitCount', 'MetricUnitBytes', 'MetricUnitSeconds', 'MetricUnitCountPerSecond', 'MetricUnitBytesPerSecond', 'MetricUnitPercent', 'MetricUnitMilliSeconds', 'MetricUnitByteSeconds', 'MetricUnitUnspecified', 'MetricUnitCores', 'MetricUnitMilliCores', 'MetricUnitNanoCores', 'MetricUnitBitsPerSecond'
  1209  	Unit MetricUnit `json:"unit,omitempty"`
  1210  	// PrimaryAggregationType - the primary aggregation type value defining how to use the values for display. Possible values include: 'None', 'Average', 'Count', 'Minimum', 'Maximum', 'Total'
  1211  	PrimaryAggregationType AggregationType `json:"primaryAggregationType,omitempty"`
  1212  	// SupportedAggregationTypes - the collection of what aggregation types are supported.
  1213  	SupportedAggregationTypes *[]AggregationType `json:"supportedAggregationTypes,omitempty"`
  1214  	// MetricAvailabilities - the collection of what aggregation intervals are available to be queried.
  1215  	MetricAvailabilities *[]Availability `json:"metricAvailabilities,omitempty"`
  1216  	// ID - the resource identifier of the metric definition.
  1217  	ID *string `json:"id,omitempty"`
  1218  	// Dimensions - the name and the display name of the dimension, i.e. it is a localizable string.
  1219  	Dimensions *[]LocalizableString `json:"dimensions,omitempty"`
  1220  }
  1221  
  1222  // DefinitionCollection represents collection of metric definitions.
  1223  type DefinitionCollection struct {
  1224  	autorest.Response `json:"-"`
  1225  	// Value - the values for the metric definitions.
  1226  	Value *[]Definition `json:"value,omitempty"`
  1227  }
  1228  
  1229  // Dimension specifies a metric dimension.
  1230  type Dimension struct {
  1231  	// Name - Name of the dimension.
  1232  	Name *string `json:"name,omitempty"`
  1233  	// Operator - the dimension operator. Only 'Include' and 'Exclude' are supported
  1234  	Operator *string `json:"operator,omitempty"`
  1235  	// Values - list of dimension values.
  1236  	Values *[]string `json:"values,omitempty"`
  1237  }
  1238  
  1239  // DimensionProperties type of operation: get, read, delete, etc.
  1240  type DimensionProperties struct {
  1241  	// Name - Name of dimension.
  1242  	Name *string `json:"name,omitempty"`
  1243  	// DisplayName - Display name of dimension.
  1244  	DisplayName *string `json:"displayName,omitempty"`
  1245  	// ToBeExportedForShoebox - Legacy usage, should not set.
  1246  	ToBeExportedForShoebox *bool `json:"toBeExportedForShoebox,omitempty"`
  1247  	// IsHidden - When set, the dimension is hidden from the customer, used in conjunction with the defaultDimensionValues field below
  1248  	IsHidden *bool `json:"isHidden,omitempty"`
  1249  	// DefaultDimensionValues - Default dimension value to be sent down for the hidden dimension during query
  1250  	DefaultDimensionValues interface{} `json:"defaultDimensionValues,omitempty"`
  1251  }
  1252  
  1253  // DynamicMetricCriteria criterion for dynamic threshold.
  1254  type DynamicMetricCriteria struct {
  1255  	// Operator - The operator used to compare the metric value against the threshold. Possible values include: 'GreaterThan', 'LessThan', 'GreaterOrLessThan'
  1256  	Operator DynamicThresholdOperator `json:"operator,omitempty"`
  1257  	// AlertSensitivity - The extent of deviation required to trigger an alert. This will affect how tight the threshold is to the metric series pattern. Possible values include: 'DynamicThresholdSensitivityLow', 'DynamicThresholdSensitivityMedium', 'DynamicThresholdSensitivityHigh'
  1258  	AlertSensitivity DynamicThresholdSensitivity `json:"alertSensitivity,omitempty"`
  1259  	// FailingPeriods - The minimum number of violations required within the selected lookback time window required to raise an alert.
  1260  	FailingPeriods *DynamicThresholdFailingPeriods `json:"failingPeriods,omitempty"`
  1261  	// IgnoreDataBefore - Use this option to set the date from which to start learning the metric historical data and calculate the dynamic thresholds (in ISO8601 format)
  1262  	IgnoreDataBefore *date.Time `json:"ignoreDataBefore,omitempty"`
  1263  	// AdditionalProperties - Unmatched properties from the message are deserialized this collection
  1264  	AdditionalProperties map[string]interface{} `json:""`
  1265  	// Name - Name of the criteria.
  1266  	Name *string `json:"name,omitempty"`
  1267  	// MetricName - Name of the metric.
  1268  	MetricName *string `json:"metricName,omitempty"`
  1269  	// MetricNamespace - Namespace of the metric.
  1270  	MetricNamespace *string `json:"metricNamespace,omitempty"`
  1271  	// TimeAggregation - the criteria time aggregation types. Possible values include: 'AggregationTypeEnumAverage', 'AggregationTypeEnumCount', 'AggregationTypeEnumMinimum', 'AggregationTypeEnumMaximum', 'AggregationTypeEnumTotal'
  1272  	TimeAggregation AggregationTypeEnum `json:"timeAggregation,omitempty"`
  1273  	// Dimensions - List of dimension conditions.
  1274  	Dimensions *[]Dimension `json:"dimensions,omitempty"`
  1275  	// SkipMetricValidation - Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped.
  1276  	SkipMetricValidation *bool `json:"skipMetricValidation,omitempty"`
  1277  	// CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion'
  1278  	CriterionType CriterionType `json:"criterionType,omitempty"`
  1279  }
  1280  
  1281  // MarshalJSON is the custom marshaler for DynamicMetricCriteria.
  1282  func (dmc DynamicMetricCriteria) MarshalJSON() ([]byte, error) {
  1283  	dmc.CriterionType = CriterionTypeDynamicThresholdCriterion
  1284  	objectMap := make(map[string]interface{})
  1285  	if dmc.Operator != "" {
  1286  		objectMap["operator"] = dmc.Operator
  1287  	}
  1288  	if dmc.AlertSensitivity != "" {
  1289  		objectMap["alertSensitivity"] = dmc.AlertSensitivity
  1290  	}
  1291  	if dmc.FailingPeriods != nil {
  1292  		objectMap["failingPeriods"] = dmc.FailingPeriods
  1293  	}
  1294  	if dmc.IgnoreDataBefore != nil {
  1295  		objectMap["ignoreDataBefore"] = dmc.IgnoreDataBefore
  1296  	}
  1297  	if dmc.Name != nil {
  1298  		objectMap["name"] = dmc.Name
  1299  	}
  1300  	if dmc.MetricName != nil {
  1301  		objectMap["metricName"] = dmc.MetricName
  1302  	}
  1303  	if dmc.MetricNamespace != nil {
  1304  		objectMap["metricNamespace"] = dmc.MetricNamespace
  1305  	}
  1306  	if dmc.TimeAggregation != "" {
  1307  		objectMap["timeAggregation"] = dmc.TimeAggregation
  1308  	}
  1309  	if dmc.Dimensions != nil {
  1310  		objectMap["dimensions"] = dmc.Dimensions
  1311  	}
  1312  	if dmc.SkipMetricValidation != nil {
  1313  		objectMap["skipMetricValidation"] = dmc.SkipMetricValidation
  1314  	}
  1315  	if dmc.CriterionType != "" {
  1316  		objectMap["criterionType"] = dmc.CriterionType
  1317  	}
  1318  	for k, v := range dmc.AdditionalProperties {
  1319  		objectMap[k] = v
  1320  	}
  1321  	return json.Marshal(objectMap)
  1322  }
  1323  
  1324  // AsCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria.
  1325  func (dmc DynamicMetricCriteria) AsCriteria() (*Criteria, bool) {
  1326  	return nil, false
  1327  }
  1328  
  1329  // AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria.
  1330  func (dmc DynamicMetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) {
  1331  	return &dmc, true
  1332  }
  1333  
  1334  // AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria.
  1335  func (dmc DynamicMetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) {
  1336  	return nil, false
  1337  }
  1338  
  1339  // AsBasicMultiMetricCriteria is the BasicMultiMetricCriteria implementation for DynamicMetricCriteria.
  1340  func (dmc DynamicMetricCriteria) AsBasicMultiMetricCriteria() (BasicMultiMetricCriteria, bool) {
  1341  	return &dmc, true
  1342  }
  1343  
  1344  // UnmarshalJSON is the custom unmarshaler for DynamicMetricCriteria struct.
  1345  func (dmc *DynamicMetricCriteria) UnmarshalJSON(body []byte) error {
  1346  	var m map[string]*json.RawMessage
  1347  	err := json.Unmarshal(body, &m)
  1348  	if err != nil {
  1349  		return err
  1350  	}
  1351  	for k, v := range m {
  1352  		switch k {
  1353  		case "operator":
  1354  			if v != nil {
  1355  				var operator DynamicThresholdOperator
  1356  				err = json.Unmarshal(*v, &operator)
  1357  				if err != nil {
  1358  					return err
  1359  				}
  1360  				dmc.Operator = operator
  1361  			}
  1362  		case "alertSensitivity":
  1363  			if v != nil {
  1364  				var alertSensitivity DynamicThresholdSensitivity
  1365  				err = json.Unmarshal(*v, &alertSensitivity)
  1366  				if err != nil {
  1367  					return err
  1368  				}
  1369  				dmc.AlertSensitivity = alertSensitivity
  1370  			}
  1371  		case "failingPeriods":
  1372  			if v != nil {
  1373  				var failingPeriods DynamicThresholdFailingPeriods
  1374  				err = json.Unmarshal(*v, &failingPeriods)
  1375  				if err != nil {
  1376  					return err
  1377  				}
  1378  				dmc.FailingPeriods = &failingPeriods
  1379  			}
  1380  		case "ignoreDataBefore":
  1381  			if v != nil {
  1382  				var ignoreDataBefore date.Time
  1383  				err = json.Unmarshal(*v, &ignoreDataBefore)
  1384  				if err != nil {
  1385  					return err
  1386  				}
  1387  				dmc.IgnoreDataBefore = &ignoreDataBefore
  1388  			}
  1389  		default:
  1390  			if v != nil {
  1391  				var additionalProperties interface{}
  1392  				err = json.Unmarshal(*v, &additionalProperties)
  1393  				if err != nil {
  1394  					return err
  1395  				}
  1396  				if dmc.AdditionalProperties == nil {
  1397  					dmc.AdditionalProperties = make(map[string]interface{})
  1398  				}
  1399  				dmc.AdditionalProperties[k] = additionalProperties
  1400  			}
  1401  		case "name":
  1402  			if v != nil {
  1403  				var name string
  1404  				err = json.Unmarshal(*v, &name)
  1405  				if err != nil {
  1406  					return err
  1407  				}
  1408  				dmc.Name = &name
  1409  			}
  1410  		case "metricName":
  1411  			if v != nil {
  1412  				var metricName string
  1413  				err = json.Unmarshal(*v, &metricName)
  1414  				if err != nil {
  1415  					return err
  1416  				}
  1417  				dmc.MetricName = &metricName
  1418  			}
  1419  		case "metricNamespace":
  1420  			if v != nil {
  1421  				var metricNamespace string
  1422  				err = json.Unmarshal(*v, &metricNamespace)
  1423  				if err != nil {
  1424  					return err
  1425  				}
  1426  				dmc.MetricNamespace = &metricNamespace
  1427  			}
  1428  		case "timeAggregation":
  1429  			if v != nil {
  1430  				var timeAggregation AggregationTypeEnum
  1431  				err = json.Unmarshal(*v, &timeAggregation)
  1432  				if err != nil {
  1433  					return err
  1434  				}
  1435  				dmc.TimeAggregation = timeAggregation
  1436  			}
  1437  		case "dimensions":
  1438  			if v != nil {
  1439  				var dimensions []Dimension
  1440  				err = json.Unmarshal(*v, &dimensions)
  1441  				if err != nil {
  1442  					return err
  1443  				}
  1444  				dmc.Dimensions = &dimensions
  1445  			}
  1446  		case "skipMetricValidation":
  1447  			if v != nil {
  1448  				var skipMetricValidation bool
  1449  				err = json.Unmarshal(*v, &skipMetricValidation)
  1450  				if err != nil {
  1451  					return err
  1452  				}
  1453  				dmc.SkipMetricValidation = &skipMetricValidation
  1454  			}
  1455  		case "criterionType":
  1456  			if v != nil {
  1457  				var criterionType CriterionType
  1458  				err = json.Unmarshal(*v, &criterionType)
  1459  				if err != nil {
  1460  					return err
  1461  				}
  1462  				dmc.CriterionType = criterionType
  1463  			}
  1464  		}
  1465  	}
  1466  
  1467  	return nil
  1468  }
  1469  
  1470  // DynamicThresholdFailingPeriods the minimum number of violations required within the selected lookback
  1471  // time window required to raise an alert.
  1472  type DynamicThresholdFailingPeriods struct {
  1473  	// NumberOfEvaluationPeriods - The number of aggregated lookback points. The lookback time window is calculated based on the aggregation granularity (windowSize) and the selected number of aggregated points.
  1474  	NumberOfEvaluationPeriods *float64 `json:"numberOfEvaluationPeriods,omitempty"`
  1475  	// MinFailingPeriodsToAlert - The number of violations to trigger an alert. Should be smaller or equal to numberOfEvaluationPeriods.
  1476  	MinFailingPeriodsToAlert *float64 `json:"minFailingPeriodsToAlert,omitempty"`
  1477  }
  1478  
  1479  // ErrorContract common error response for all Azure Resource Manager APIs to return error details for
  1480  // failed operations. (This also follows the OData error response format.)
  1481  type ErrorContract struct {
  1482  	// Error - The error object.
  1483  	Error *ErrorResponse `json:"error,omitempty"`
  1484  }
  1485  
  1486  // ErrorResponse describes the format of Error response.
  1487  type ErrorResponse struct {
  1488  	// Code - Error code
  1489  	Code *string `json:"code,omitempty"`
  1490  	// Message - Error message indicating why the operation failed.
  1491  	Message *string `json:"message,omitempty"`
  1492  }
  1493  
  1494  // LocalizableString the localizable string class.
  1495  type LocalizableString struct {
  1496  	// Value - the invariant value.
  1497  	Value *string `json:"value,omitempty"`
  1498  	// LocalizedValue - the locale specific value.
  1499  	LocalizedValue *string `json:"localizedValue,omitempty"`
  1500  }
  1501  
  1502  // LogSpecification log specification of operation.
  1503  type LogSpecification struct {
  1504  	// Name - Name of log specification.
  1505  	Name *string `json:"name,omitempty"`
  1506  	// DisplayName - Display name of log specification.
  1507  	DisplayName *string `json:"displayName,omitempty"`
  1508  	// BlobDuration - Blob duration of specification.
  1509  	BlobDuration *string `json:"blobDuration,omitempty"`
  1510  }
  1511  
  1512  // MetadataValue represents a metric metadata value.
  1513  type MetadataValue struct {
  1514  	// Name - the name of the metadata.
  1515  	Name *LocalizableString `json:"name,omitempty"`
  1516  	// Value - the value of the metadata.
  1517  	Value *string `json:"value,omitempty"`
  1518  }
  1519  
  1520  // Metric the result data of a query.
  1521  type Metric struct {
  1522  	// ID - the metric Id.
  1523  	ID *string `json:"id,omitempty"`
  1524  	// Type - the resource type of the metric resource.
  1525  	Type *string `json:"type,omitempty"`
  1526  	// Name - the name and the display name of the metric, i.e. it is localizable string.
  1527  	Name *LocalizableString `json:"name,omitempty"`
  1528  	// DisplayDescription - Detailed description of this metric.
  1529  	DisplayDescription *string `json:"displayDescription,omitempty"`
  1530  	// ErrorCode - 'Success' or the error details on query failures for this metric.
  1531  	ErrorCode *string `json:"errorCode,omitempty"`
  1532  	// ErrorMessage - Error message encountered querying this specific metric.
  1533  	ErrorMessage *string `json:"errorMessage,omitempty"`
  1534  	// Unit - The unit of the metric. Possible values include: 'UnitCount', 'UnitBytes', 'UnitSeconds', 'UnitCountPerSecond', 'UnitBytesPerSecond', 'UnitPercent', 'UnitMilliSeconds', 'UnitByteSeconds', 'UnitUnspecified', 'UnitCores', 'UnitMilliCores', 'UnitNanoCores', 'UnitBitsPerSecond'
  1535  	Unit Unit `json:"unit,omitempty"`
  1536  	// Timeseries - the time series returned when a data query is performed.
  1537  	Timeseries *[]TimeSeriesElement `json:"timeseries,omitempty"`
  1538  }
  1539  
  1540  // BasicMultiMetricCriteria the types of conditions for a multi resource alert.
  1541  type BasicMultiMetricCriteria interface {
  1542  	AsCriteria() (*Criteria, bool)
  1543  	AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool)
  1544  	AsMultiMetricCriteria() (*MultiMetricCriteria, bool)
  1545  }
  1546  
  1547  // MultiMetricCriteria the types of conditions for a multi resource alert.
  1548  type MultiMetricCriteria struct {
  1549  	// AdditionalProperties - Unmatched properties from the message are deserialized this collection
  1550  	AdditionalProperties map[string]interface{} `json:""`
  1551  	// Name - Name of the criteria.
  1552  	Name *string `json:"name,omitempty"`
  1553  	// MetricName - Name of the metric.
  1554  	MetricName *string `json:"metricName,omitempty"`
  1555  	// MetricNamespace - Namespace of the metric.
  1556  	MetricNamespace *string `json:"metricNamespace,omitempty"`
  1557  	// TimeAggregation - the criteria time aggregation types. Possible values include: 'AggregationTypeEnumAverage', 'AggregationTypeEnumCount', 'AggregationTypeEnumMinimum', 'AggregationTypeEnumMaximum', 'AggregationTypeEnumTotal'
  1558  	TimeAggregation AggregationTypeEnum `json:"timeAggregation,omitempty"`
  1559  	// Dimensions - List of dimension conditions.
  1560  	Dimensions *[]Dimension `json:"dimensions,omitempty"`
  1561  	// SkipMetricValidation - Allows creating an alert rule on a custom metric that isn't yet emitted, by causing the metric validation to be skipped.
  1562  	SkipMetricValidation *bool `json:"skipMetricValidation,omitempty"`
  1563  	// CriterionType - Possible values include: 'CriterionTypeMultiMetricCriteria', 'CriterionTypeStaticThresholdCriterion', 'CriterionTypeDynamicThresholdCriterion'
  1564  	CriterionType CriterionType `json:"criterionType,omitempty"`
  1565  }
  1566  
  1567  func unmarshalBasicMultiMetricCriteria(body []byte) (BasicMultiMetricCriteria, error) {
  1568  	var m map[string]interface{}
  1569  	err := json.Unmarshal(body, &m)
  1570  	if err != nil {
  1571  		return nil, err
  1572  	}
  1573  
  1574  	switch m["criterionType"] {
  1575  	case string(CriterionTypeStaticThresholdCriterion):
  1576  		var c Criteria
  1577  		err := json.Unmarshal(body, &c)
  1578  		return c, err
  1579  	case string(CriterionTypeDynamicThresholdCriterion):
  1580  		var dmc DynamicMetricCriteria
  1581  		err := json.Unmarshal(body, &dmc)
  1582  		return dmc, err
  1583  	default:
  1584  		var mmc MultiMetricCriteria
  1585  		err := json.Unmarshal(body, &mmc)
  1586  		return mmc, err
  1587  	}
  1588  }
  1589  func unmarshalBasicMultiMetricCriteriaArray(body []byte) ([]BasicMultiMetricCriteria, error) {
  1590  	var rawMessages []*json.RawMessage
  1591  	err := json.Unmarshal(body, &rawMessages)
  1592  	if err != nil {
  1593  		return nil, err
  1594  	}
  1595  
  1596  	mmcArray := make([]BasicMultiMetricCriteria, len(rawMessages))
  1597  
  1598  	for index, rawMessage := range rawMessages {
  1599  		mmc, err := unmarshalBasicMultiMetricCriteria(*rawMessage)
  1600  		if err != nil {
  1601  			return nil, err
  1602  		}
  1603  		mmcArray[index] = mmc
  1604  	}
  1605  	return mmcArray, nil
  1606  }
  1607  
  1608  // MarshalJSON is the custom marshaler for MultiMetricCriteria.
  1609  func (mmc MultiMetricCriteria) MarshalJSON() ([]byte, error) {
  1610  	mmc.CriterionType = CriterionTypeMultiMetricCriteria
  1611  	objectMap := make(map[string]interface{})
  1612  	if mmc.Name != nil {
  1613  		objectMap["name"] = mmc.Name
  1614  	}
  1615  	if mmc.MetricName != nil {
  1616  		objectMap["metricName"] = mmc.MetricName
  1617  	}
  1618  	if mmc.MetricNamespace != nil {
  1619  		objectMap["metricNamespace"] = mmc.MetricNamespace
  1620  	}
  1621  	if mmc.TimeAggregation != "" {
  1622  		objectMap["timeAggregation"] = mmc.TimeAggregation
  1623  	}
  1624  	if mmc.Dimensions != nil {
  1625  		objectMap["dimensions"] = mmc.Dimensions
  1626  	}
  1627  	if mmc.SkipMetricValidation != nil {
  1628  		objectMap["skipMetricValidation"] = mmc.SkipMetricValidation
  1629  	}
  1630  	if mmc.CriterionType != "" {
  1631  		objectMap["criterionType"] = mmc.CriterionType
  1632  	}
  1633  	for k, v := range mmc.AdditionalProperties {
  1634  		objectMap[k] = v
  1635  	}
  1636  	return json.Marshal(objectMap)
  1637  }
  1638  
  1639  // AsCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria.
  1640  func (mmc MultiMetricCriteria) AsCriteria() (*Criteria, bool) {
  1641  	return nil, false
  1642  }
  1643  
  1644  // AsDynamicMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria.
  1645  func (mmc MultiMetricCriteria) AsDynamicMetricCriteria() (*DynamicMetricCriteria, bool) {
  1646  	return nil, false
  1647  }
  1648  
  1649  // AsMultiMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria.
  1650  func (mmc MultiMetricCriteria) AsMultiMetricCriteria() (*MultiMetricCriteria, bool) {
  1651  	return &mmc, true
  1652  }
  1653  
  1654  // AsBasicMultiMetricCriteria is the BasicMultiMetricCriteria implementation for MultiMetricCriteria.
  1655  func (mmc MultiMetricCriteria) AsBasicMultiMetricCriteria() (BasicMultiMetricCriteria, bool) {
  1656  	return &mmc, true
  1657  }
  1658  
  1659  // UnmarshalJSON is the custom unmarshaler for MultiMetricCriteria struct.
  1660  func (mmc *MultiMetricCriteria) UnmarshalJSON(body []byte) error {
  1661  	var m map[string]*json.RawMessage
  1662  	err := json.Unmarshal(body, &m)
  1663  	if err != nil {
  1664  		return err
  1665  	}
  1666  	for k, v := range m {
  1667  		switch k {
  1668  		default:
  1669  			if v != nil {
  1670  				var additionalProperties interface{}
  1671  				err = json.Unmarshal(*v, &additionalProperties)
  1672  				if err != nil {
  1673  					return err
  1674  				}
  1675  				if mmc.AdditionalProperties == nil {
  1676  					mmc.AdditionalProperties = make(map[string]interface{})
  1677  				}
  1678  				mmc.AdditionalProperties[k] = additionalProperties
  1679  			}
  1680  		case "name":
  1681  			if v != nil {
  1682  				var name string
  1683  				err = json.Unmarshal(*v, &name)
  1684  				if err != nil {
  1685  					return err
  1686  				}
  1687  				mmc.Name = &name
  1688  			}
  1689  		case "metricName":
  1690  			if v != nil {
  1691  				var metricName string
  1692  				err = json.Unmarshal(*v, &metricName)
  1693  				if err != nil {
  1694  					return err
  1695  				}
  1696  				mmc.MetricName = &metricName
  1697  			}
  1698  		case "metricNamespace":
  1699  			if v != nil {
  1700  				var metricNamespace string
  1701  				err = json.Unmarshal(*v, &metricNamespace)
  1702  				if err != nil {
  1703  					return err
  1704  				}
  1705  				mmc.MetricNamespace = &metricNamespace
  1706  			}
  1707  		case "timeAggregation":
  1708  			if v != nil {
  1709  				var timeAggregation AggregationTypeEnum
  1710  				err = json.Unmarshal(*v, &timeAggregation)
  1711  				if err != nil {
  1712  					return err
  1713  				}
  1714  				mmc.TimeAggregation = timeAggregation
  1715  			}
  1716  		case "dimensions":
  1717  			if v != nil {
  1718  				var dimensions []Dimension
  1719  				err = json.Unmarshal(*v, &dimensions)
  1720  				if err != nil {
  1721  					return err
  1722  				}
  1723  				mmc.Dimensions = &dimensions
  1724  			}
  1725  		case "skipMetricValidation":
  1726  			if v != nil {
  1727  				var skipMetricValidation bool
  1728  				err = json.Unmarshal(*v, &skipMetricValidation)
  1729  				if err != nil {
  1730  					return err
  1731  				}
  1732  				mmc.SkipMetricValidation = &skipMetricValidation
  1733  			}
  1734  		case "criterionType":
  1735  			if v != nil {
  1736  				var criterionType CriterionType
  1737  				err = json.Unmarshal(*v, &criterionType)
  1738  				if err != nil {
  1739  					return err
  1740  				}
  1741  				mmc.CriterionType = criterionType
  1742  			}
  1743  		}
  1744  	}
  1745  
  1746  	return nil
  1747  }
  1748  
  1749  // Namespace metric namespace class specifies the metadata for a metric namespace.
  1750  type Namespace struct {
  1751  	// ID - The ID of the metric namespace.
  1752  	ID *string `json:"id,omitempty"`
  1753  	// Type - The type of the namespace.
  1754  	Type *string `json:"type,omitempty"`
  1755  	// Name - The escaped name of the namespace.
  1756  	Name *string `json:"name,omitempty"`
  1757  	// Classification - Kind of namespace. Possible values include: 'Platform', 'Custom', 'Qos'
  1758  	Classification NamespaceClassification `json:"classification,omitempty"`
  1759  	// Properties - Properties which include the fully qualified namespace name.
  1760  	Properties *NamespaceName `json:"properties,omitempty"`
  1761  }
  1762  
  1763  // NamespaceCollection represents collection of metric namespaces.
  1764  type NamespaceCollection struct {
  1765  	autorest.Response `json:"-"`
  1766  	// Value - The values for the metric namespaces.
  1767  	Value *[]Namespace `json:"value,omitempty"`
  1768  }
  1769  
  1770  // NamespaceName the fully qualified metric namespace name.
  1771  type NamespaceName struct {
  1772  	// MetricNamespaceName - The metric namespace name.
  1773  	MetricNamespaceName *string `json:"metricNamespaceName,omitempty"`
  1774  }
  1775  
  1776  // Operation microsoft Insights API operation definition.
  1777  type Operation struct {
  1778  	// Name - Operation name: {provider}/{resource}/{operation}
  1779  	Name *string `json:"name,omitempty"`
  1780  	// IsDataAction - Property to specify whether the action is a data action.
  1781  	IsDataAction *bool `json:"isDataAction,omitempty"`
  1782  	// Display - Display metadata associated with the operation.
  1783  	Display *OperationDisplay `json:"display,omitempty"`
  1784  	// OperationProperties - Properties of operation, include metric specifications.
  1785  	*OperationProperties `json:"properties,omitempty"`
  1786  }
  1787  
  1788  // MarshalJSON is the custom marshaler for Operation.
  1789  func (o Operation) MarshalJSON() ([]byte, error) {
  1790  	objectMap := make(map[string]interface{})
  1791  	if o.Name != nil {
  1792  		objectMap["name"] = o.Name
  1793  	}
  1794  	if o.IsDataAction != nil {
  1795  		objectMap["isDataAction"] = o.IsDataAction
  1796  	}
  1797  	if o.Display != nil {
  1798  		objectMap["display"] = o.Display
  1799  	}
  1800  	if o.OperationProperties != nil {
  1801  		objectMap["properties"] = o.OperationProperties
  1802  	}
  1803  	return json.Marshal(objectMap)
  1804  }
  1805  
  1806  // UnmarshalJSON is the custom unmarshaler for Operation struct.
  1807  func (o *Operation) UnmarshalJSON(body []byte) error {
  1808  	var m map[string]*json.RawMessage
  1809  	err := json.Unmarshal(body, &m)
  1810  	if err != nil {
  1811  		return err
  1812  	}
  1813  	for k, v := range m {
  1814  		switch k {
  1815  		case "name":
  1816  			if v != nil {
  1817  				var name string
  1818  				err = json.Unmarshal(*v, &name)
  1819  				if err != nil {
  1820  					return err
  1821  				}
  1822  				o.Name = &name
  1823  			}
  1824  		case "isDataAction":
  1825  			if v != nil {
  1826  				var isDataAction bool
  1827  				err = json.Unmarshal(*v, &isDataAction)
  1828  				if err != nil {
  1829  					return err
  1830  				}
  1831  				o.IsDataAction = &isDataAction
  1832  			}
  1833  		case "display":
  1834  			if v != nil {
  1835  				var display OperationDisplay
  1836  				err = json.Unmarshal(*v, &display)
  1837  				if err != nil {
  1838  					return err
  1839  				}
  1840  				o.Display = &display
  1841  			}
  1842  		case "properties":
  1843  			if v != nil {
  1844  				var operationProperties OperationProperties
  1845  				err = json.Unmarshal(*v, &operationProperties)
  1846  				if err != nil {
  1847  					return err
  1848  				}
  1849  				o.OperationProperties = &operationProperties
  1850  			}
  1851  		}
  1852  	}
  1853  
  1854  	return nil
  1855  }
  1856  
  1857  // OperationDisplay display metadata associated with the operation.
  1858  type OperationDisplay struct {
  1859  	// Publisher - The publisher of this operation.
  1860  	Publisher *string `json:"publisher,omitempty"`
  1861  	// Provider - Service provider: Microsoft.Insights
  1862  	Provider *string `json:"provider,omitempty"`
  1863  	// Resource - Resource on which the operation is performed: AlertRules, Autoscale, etc.
  1864  	Resource *string `json:"resource,omitempty"`
  1865  	// Operation - Operation type: Read, write, delete, etc.
  1866  	Operation *string `json:"operation,omitempty"`
  1867  	// Description - The description of the operation.
  1868  	Description *string `json:"description,omitempty"`
  1869  }
  1870  
  1871  // OperationListResult result of the request to list Microsoft.Insights operations. It contains a list of
  1872  // operations and a URL link to get the next set of results.
  1873  type OperationListResult struct {
  1874  	autorest.Response `json:"-"`
  1875  	// Value - List of operations supported by the Microsoft.Insights provider.
  1876  	Value *[]Operation `json:"value,omitempty"`
  1877  	// NextLink - URL to get the next set of operation list results if there are any.
  1878  	NextLink *string `json:"nextLink,omitempty"`
  1879  }
  1880  
  1881  // OperationProperties properties of operation, include metric specifications.
  1882  type OperationProperties struct {
  1883  	// ServiceSpecification - One property of operation, include metric specifications.
  1884  	ServiceSpecification *ServiceSpecification `json:"serviceSpecification,omitempty"`
  1885  }
  1886  
  1887  // Resource an azure resource object
  1888  type Resource struct {
  1889  	// ID - READ-ONLY; Azure resource Id
  1890  	ID *string `json:"id,omitempty"`
  1891  	// Name - READ-ONLY; Azure resource name
  1892  	Name *string `json:"name,omitempty"`
  1893  	// Type - READ-ONLY; Azure resource type
  1894  	Type *string `json:"type,omitempty"`
  1895  	// Location - Resource location
  1896  	Location *string `json:"location,omitempty"`
  1897  	// Tags - Resource tags
  1898  	Tags map[string]*string `json:"tags"`
  1899  }
  1900  
  1901  // MarshalJSON is the custom marshaler for Resource.
  1902  func (r Resource) MarshalJSON() ([]byte, error) {
  1903  	objectMap := make(map[string]interface{})
  1904  	if r.Location != nil {
  1905  		objectMap["location"] = r.Location
  1906  	}
  1907  	if r.Tags != nil {
  1908  		objectMap["tags"] = r.Tags
  1909  	}
  1910  	return json.Marshal(objectMap)
  1911  }
  1912  
  1913  // Response the response to a metrics query.
  1914  type Response struct {
  1915  	autorest.Response `json:"-"`
  1916  	// Cost - The integer value representing the relative cost of the query.
  1917  	Cost *float64 `json:"cost,omitempty"`
  1918  	// Timespan - The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'.  This may be adjusted in the future and returned back from what was originally requested.
  1919  	Timespan *string `json:"timespan,omitempty"`
  1920  	// Interval - The interval (window size) for which the metric data was returned in.  This may be adjusted in the future and returned back from what was originally requested.  This is not present if a metadata request was made.
  1921  	Interval *string `json:"interval,omitempty"`
  1922  	// Namespace - The namespace of the metrics being queried
  1923  	Namespace *string `json:"namespace,omitempty"`
  1924  	// Resourceregion - The region of the resource being queried for metrics.
  1925  	Resourceregion *string `json:"resourceregion,omitempty"`
  1926  	// Value - the value of the collection.
  1927  	Value *[]Metric `json:"value,omitempty"`
  1928  }
  1929  
  1930  // ServiceSpecification one property of operation, include log specifications.
  1931  type ServiceSpecification struct {
  1932  	// LogSpecifications - Log specifications of operation.
  1933  	LogSpecifications *[]LogSpecification `json:"logSpecifications,omitempty"`
  1934  	// MetricSpecifications - Metric specifications of operation.
  1935  	MetricSpecifications *[]Specification `json:"metricSpecifications,omitempty"`
  1936  	// LegacyMetricSpecifications - Legacy Metric specifications for operation. Deprecated, do not use.
  1937  	LegacyMetricSpecifications interface{} `json:"legacyMetricSpecifications,omitempty"`
  1938  }
  1939  
  1940  // SingleBaseline the baseline values for a single sensitivity value.
  1941  type SingleBaseline struct {
  1942  	// Sensitivity - the sensitivity of the baseline. Possible values include: 'Low', 'Medium', 'High'
  1943  	Sensitivity BaselineSensitivity `json:"sensitivity,omitempty"`
  1944  	// LowThresholds - The low thresholds of the baseline.
  1945  	LowThresholds *[]float64 `json:"lowThresholds,omitempty"`
  1946  	// HighThresholds - The high thresholds of the baseline.
  1947  	HighThresholds *[]float64 `json:"highThresholds,omitempty"`
  1948  }
  1949  
  1950  // SingleDimension the metric dimension name and value.
  1951  type SingleDimension struct {
  1952  	// Name - Name of the dimension.
  1953  	Name *string `json:"name,omitempty"`
  1954  	// Value - Value of the dimension.
  1955  	Value *string `json:"value,omitempty"`
  1956  }
  1957  
  1958  // SingleMetricBaseline the baseline results of a single metric.
  1959  type SingleMetricBaseline struct {
  1960  	// ID - The metric baseline Id.
  1961  	ID *string `json:"id,omitempty"`
  1962  	// Type - The resource type of the metric baseline resource.
  1963  	Type *string `json:"type,omitempty"`
  1964  	// Name - The name of the metric for which the baselines were retrieved.
  1965  	Name *string `json:"name,omitempty"`
  1966  	// BaselinesProperties - The metric baseline properties of the metric.
  1967  	*BaselinesProperties `json:"properties,omitempty"`
  1968  }
  1969  
  1970  // MarshalJSON is the custom marshaler for SingleMetricBaseline.
  1971  func (smb SingleMetricBaseline) MarshalJSON() ([]byte, error) {
  1972  	objectMap := make(map[string]interface{})
  1973  	if smb.ID != nil {
  1974  		objectMap["id"] = smb.ID
  1975  	}
  1976  	if smb.Type != nil {
  1977  		objectMap["type"] = smb.Type
  1978  	}
  1979  	if smb.Name != nil {
  1980  		objectMap["name"] = smb.Name
  1981  	}
  1982  	if smb.BaselinesProperties != nil {
  1983  		objectMap["properties"] = smb.BaselinesProperties
  1984  	}
  1985  	return json.Marshal(objectMap)
  1986  }
  1987  
  1988  // UnmarshalJSON is the custom unmarshaler for SingleMetricBaseline struct.
  1989  func (smb *SingleMetricBaseline) UnmarshalJSON(body []byte) error {
  1990  	var m map[string]*json.RawMessage
  1991  	err := json.Unmarshal(body, &m)
  1992  	if err != nil {
  1993  		return err
  1994  	}
  1995  	for k, v := range m {
  1996  		switch k {
  1997  		case "id":
  1998  			if v != nil {
  1999  				var ID string
  2000  				err = json.Unmarshal(*v, &ID)
  2001  				if err != nil {
  2002  					return err
  2003  				}
  2004  				smb.ID = &ID
  2005  			}
  2006  		case "type":
  2007  			if v != nil {
  2008  				var typeVar string
  2009  				err = json.Unmarshal(*v, &typeVar)
  2010  				if err != nil {
  2011  					return err
  2012  				}
  2013  				smb.Type = &typeVar
  2014  			}
  2015  		case "name":
  2016  			if v != nil {
  2017  				var name string
  2018  				err = json.Unmarshal(*v, &name)
  2019  				if err != nil {
  2020  					return err
  2021  				}
  2022  				smb.Name = &name
  2023  			}
  2024  		case "properties":
  2025  			if v != nil {
  2026  				var baselinesProperties BaselinesProperties
  2027  				err = json.Unmarshal(*v, &baselinesProperties)
  2028  				if err != nil {
  2029  					return err
  2030  				}
  2031  				smb.BaselinesProperties = &baselinesProperties
  2032  			}
  2033  		}
  2034  	}
  2035  
  2036  	return nil
  2037  }
  2038  
  2039  // Specification metric specification of operation.
  2040  type Specification struct {
  2041  	// Name - The name of the metric.
  2042  	Name *string `json:"name,omitempty"`
  2043  	// DisplayName - Display name of the metric.
  2044  	DisplayName *string `json:"displayName,omitempty"`
  2045  	// DisplayDescription - Display description of the metric.
  2046  	DisplayDescription *string `json:"displayDescription,omitempty"`
  2047  	// Unit - The metric unit. Possible values include: Count,Bytes,Seconds,Percent,CountPerSecond,BytesPerSecond,MilliSeconds,ByteSeconds,Unspecified,BitsPerSecond,Cores,MilliCores,NanoCores
  2048  	Unit *string `json:"unit,omitempty"`
  2049  	// AggregationType - The default metric aggregation type. Possible values include: Total,Average,Maximum,Minimum,Count
  2050  	AggregationType *string `json:"aggregationType,omitempty"`
  2051  	// SupportedAggregationTypes - The supported aggregation types for the metrics.
  2052  	SupportedAggregationTypes *[]string `json:"supportedAggregationTypes,omitempty"`
  2053  	// SupportedTimeGrainTypes - The supported time grain types for the metrics.
  2054  	SupportedTimeGrainTypes *[]string `json:"supportedTimeGrainTypes,omitempty"`
  2055  	// Availabilities - The supported time grain types for the metrics.
  2056  	Availabilities *[]string `json:"availabilities,omitempty"`
  2057  	// LockAggregationType - The metric lock aggregation type.
  2058  	LockAggregationType *string `json:"lockAggregationType,omitempty"`
  2059  	// Category - Category or type of metric.
  2060  	Category *string `json:"category,omitempty"`
  2061  	// Dimensions - The dimensions of metric.
  2062  	Dimensions *[]DimensionProperties `json:"dimensions,omitempty"`
  2063  	// FillGapWithZero - Property to specify whether to fill empty gaps with zero.
  2064  	FillGapWithZero *bool `json:"fillGapWithZero,omitempty"`
  2065  	// InternalMetricName - The internal metric name.
  2066  	InternalMetricName *string `json:"internalMetricName,omitempty"`
  2067  }
  2068  
  2069  // SubscriptionScopeMetric the result data of a query.
  2070  type SubscriptionScopeMetric struct {
  2071  	// ID - the metric Id.
  2072  	ID *string `json:"id,omitempty"`
  2073  	// Type - the resource type of the metric resource.
  2074  	Type *string `json:"type,omitempty"`
  2075  	// Name - the name and the display name of the metric, i.e. it is localizable string.
  2076  	Name *LocalizableString `json:"name,omitempty"`
  2077  	// DisplayDescription - Detailed description of this metric.
  2078  	DisplayDescription *string `json:"displayDescription,omitempty"`
  2079  	// ErrorCode - 'Success' or the error details on query failures for this metric.
  2080  	ErrorCode *string `json:"errorCode,omitempty"`
  2081  	// ErrorMessage - Error message encountered querying this specific metric.
  2082  	ErrorMessage *string `json:"errorMessage,omitempty"`
  2083  	// Unit - The unit of the metric. Possible values include: 'MetricUnitCount', 'MetricUnitBytes', 'MetricUnitSeconds', 'MetricUnitCountPerSecond', 'MetricUnitBytesPerSecond', 'MetricUnitPercent', 'MetricUnitMilliSeconds', 'MetricUnitByteSeconds', 'MetricUnitUnspecified', 'MetricUnitCores', 'MetricUnitMilliCores', 'MetricUnitNanoCores', 'MetricUnitBitsPerSecond'
  2084  	Unit MetricUnit `json:"unit,omitempty"`
  2085  	// Timeseries - the time series returned when a data query is performed.
  2086  	Timeseries *[]TimeSeriesElement `json:"timeseries,omitempty"`
  2087  }
  2088  
  2089  // SubscriptionScopeMetricDefinition metric definition class specifies the metadata for a metric.
  2090  type SubscriptionScopeMetricDefinition struct {
  2091  	// IsDimensionRequired - Flag to indicate whether the dimension is required.
  2092  	IsDimensionRequired *bool `json:"isDimensionRequired,omitempty"`
  2093  	// ResourceID - the resource identifier of the resource that emitted the metric.
  2094  	ResourceID *string `json:"resourceId,omitempty"`
  2095  	// Namespace - the namespace the metric belongs to.
  2096  	Namespace *string `json:"namespace,omitempty"`
  2097  	// Name - the name and the display name of the metric, i.e. it is a localizable string.
  2098  	Name *LocalizableString `json:"name,omitempty"`
  2099  	// DisplayDescription - Detailed description of this metric.
  2100  	DisplayDescription *string `json:"displayDescription,omitempty"`
  2101  	// Category - Custom category name for this metric.
  2102  	Category *string `json:"category,omitempty"`
  2103  	// MetricClass - The class of the metric. Possible values include: 'MetricClassAvailability', 'MetricClassTransactions', 'MetricClassErrors', 'MetricClassLatency', 'MetricClassSaturation'
  2104  	MetricClass MetricClass `json:"metricClass,omitempty"`
  2105  	// Unit - the unit of the metric. Possible values include: 'MetricUnitCount', 'MetricUnitBytes', 'MetricUnitSeconds', 'MetricUnitCountPerSecond', 'MetricUnitBytesPerSecond', 'MetricUnitPercent', 'MetricUnitMilliSeconds', 'MetricUnitByteSeconds', 'MetricUnitUnspecified', 'MetricUnitCores', 'MetricUnitMilliCores', 'MetricUnitNanoCores', 'MetricUnitBitsPerSecond'
  2106  	Unit MetricUnit `json:"unit,omitempty"`
  2107  	// PrimaryAggregationType - the primary aggregation type value defining how to use the values for display. Possible values include: 'MetricAggregationTypeNone', 'MetricAggregationTypeAverage', 'MetricAggregationTypeCount', 'MetricAggregationTypeMinimum', 'MetricAggregationTypeMaximum', 'MetricAggregationTypeTotal'
  2108  	PrimaryAggregationType MetricAggregationType `json:"primaryAggregationType,omitempty"`
  2109  	// SupportedAggregationTypes - the collection of what aggregation types are supported.
  2110  	SupportedAggregationTypes *[]MetricAggregationType `json:"supportedAggregationTypes,omitempty"`
  2111  	// MetricAvailabilities - the collection of what aggregation intervals are available to be queried.
  2112  	MetricAvailabilities *[]Availability `json:"metricAvailabilities,omitempty"`
  2113  	// ID - the resource identifier of the metric definition.
  2114  	ID *string `json:"id,omitempty"`
  2115  	// Dimensions - the name and the display name of the dimension, i.e. it is a localizable string.
  2116  	Dimensions *[]LocalizableString `json:"dimensions,omitempty"`
  2117  }
  2118  
  2119  // SubscriptionScopeMetricDefinitionCollection represents collection of metric definitions.
  2120  type SubscriptionScopeMetricDefinitionCollection struct {
  2121  	autorest.Response `json:"-"`
  2122  	// Value - The values for the metric definitions.
  2123  	Value *[]SubscriptionScopeMetricDefinition `json:"value,omitempty"`
  2124  }
  2125  
  2126  // SubscriptionScopeMetricResponse the response to a subscription scope metrics query.
  2127  type SubscriptionScopeMetricResponse struct {
  2128  	autorest.Response `json:"-"`
  2129  	// Cost - The integer value representing the relative cost of the query.
  2130  	Cost *float64 `json:"cost,omitempty"`
  2131  	// Timespan - The timespan for which the data was retrieved. Its value consists of two datetimes concatenated, separated by '/'.  This may be adjusted in the future and returned back from what was originally requested.
  2132  	Timespan *string `json:"timespan,omitempty"`
  2133  	// Interval - The interval (window size) for which the metric data was returned in.  This may be adjusted in the future and returned back from what was originally requested.  This is not present if a metadata request was made.
  2134  	Interval *string `json:"interval,omitempty"`
  2135  	// Namespace - The namespace of the metrics being queried
  2136  	Namespace *string `json:"namespace,omitempty"`
  2137  	// Resourceregion - The region of the resource being queried for metrics.
  2138  	Resourceregion *string `json:"resourceregion,omitempty"`
  2139  	// Value - the value of the collection.
  2140  	Value *[]SubscriptionScopeMetric `json:"value,omitempty"`
  2141  }
  2142  
  2143  // SubscriptionScopeMetricsRequestBodyParameters query parameters can also be specified in the body,
  2144  // specifying the same parameter in both the body and query parameters will result in an error.
  2145  type SubscriptionScopeMetricsRequestBodyParameters struct {
  2146  	// Timespan - The timespan of the query. It is a string with the following format 'startDateTime_ISO/endDateTime_ISO'.
  2147  	Timespan *string `json:"timespan,omitempty"`
  2148  	// Interval - The interval (i.e. timegrain) of the query.
  2149  	Interval *string `json:"interval,omitempty"`
  2150  	// MetricNames - The names of the metrics (comma separated) to retrieve.
  2151  	MetricNames *string `json:"metricNames,omitempty"`
  2152  	// Aggregation - The list of aggregation types (comma separated) to retrieve.
  2153  	Aggregation *string `json:"aggregation,omitempty"`
  2154  	// Filter - The **$filter** is used to reduce the set of metric data returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series of C where A = a1 and B = b1 or b2<br>**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**<br>- Invalid variant:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**$filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**.
  2155  	Filter *string `json:"filter,omitempty"`
  2156  	// Top - The maximum number of records to retrieve.
  2157  	// Valid only if $filter is specified.
  2158  	// Defaults to 10.
  2159  	Top *int32 `json:"top,omitempty"`
  2160  	// OrderBy - The aggregation to use for sorting results and the direction of the sort.
  2161  	// Only one order can be specified.
  2162  	// Examples: sum asc.
  2163  	OrderBy *string `json:"orderBy,omitempty"`
  2164  	// RollUpBy - Dimension name(s) to rollup results by. For example if you only want to see metric values with a filter like 'City eq Seattle or City eq Tacoma' but don't want to see separate values for each city, you can specify 'RollUpBy=City' to see the results for Seattle and Tacoma rolled up into one timeseries.
  2165  	RollUpBy *string `json:"rollUpBy,omitempty"`
  2166  	// ResultType - Reduces the set of data collected. The syntax allowed depends on the operation. See the operation's description for details. Possible values include: 'Data', 'Metadata'
  2167  	ResultType MetricResultType `json:"resultType,omitempty"`
  2168  	// MetricNamespace - Metric namespace where the metrics you want reside.
  2169  	MetricNamespace *string `json:"metricNamespace,omitempty"`
  2170  	// AutoAdjustTimegrain - When set to true, if the timespan passed in is not supported by this metric, the API will return the result using the closest supported timespan. When set to false, an error is returned for invalid timespan parameters. Defaults to false.
  2171  	AutoAdjustTimegrain *bool `json:"autoAdjustTimegrain,omitempty"`
  2172  	// ValidateDimensions - When set to false, invalid filter parameter values will be ignored. When set to true, an error is returned for invalid filter parameters. Defaults to true.
  2173  	ValidateDimensions *bool `json:"validateDimensions,omitempty"`
  2174  }
  2175  
  2176  // TimeSeriesBaseline the baseline values for a single time series.
  2177  type TimeSeriesBaseline struct {
  2178  	// Aggregation - The aggregation type of the metric.
  2179  	Aggregation *string `json:"aggregation,omitempty"`
  2180  	// Dimensions - The dimensions of this time series.
  2181  	Dimensions *[]SingleDimension `json:"dimensions,omitempty"`
  2182  	// Timestamps - The list of timestamps of the baselines.
  2183  	Timestamps *[]date.Time `json:"timestamps,omitempty"`
  2184  	// Data - The baseline values for each sensitivity.
  2185  	Data *[]SingleBaseline `json:"data,omitempty"`
  2186  	// MetadataValues - The baseline metadata values.
  2187  	MetadataValues *[]BaselineMetadata `json:"metadataValues,omitempty"`
  2188  }
  2189  
  2190  // TimeSeriesElement a time series result type. The discriminator value is always TimeSeries in this case.
  2191  type TimeSeriesElement struct {
  2192  	// Metadatavalues - the metadata values returned if $filter was specified in the call.
  2193  	Metadatavalues *[]MetadataValue `json:"metadatavalues,omitempty"`
  2194  	// Data - An array of data points representing the metric values.  This is only returned if a result type of data is specified.
  2195  	Data *[]Value `json:"data,omitempty"`
  2196  }
  2197  
  2198  // Value represents a metric value.
  2199  type Value struct {
  2200  	// TimeStamp - the timestamp for the metric value in ISO 8601 format.
  2201  	TimeStamp *date.Time `json:"timeStamp,omitempty"`
  2202  	// Average - the average value in the time range.
  2203  	Average *float64 `json:"average,omitempty"`
  2204  	// Minimum - the least value in the time range.
  2205  	Minimum *float64 `json:"minimum,omitempty"`
  2206  	// Maximum - the greatest value in the time range.
  2207  	Maximum *float64 `json:"maximum,omitempty"`
  2208  	// Total - the sum of all of the values in the time range.
  2209  	Total *float64 `json:"total,omitempty"`
  2210  	// Count - the number of samples in the time range. Can be used to determine the number of values that contributed to the average value.
  2211  	Count *float64 `json:"count,omitempty"`
  2212  }
  2213  
  2214  // WebtestLocationAvailabilityCriteria specifies the metric alert rule criteria for a web test resource.
  2215  type WebtestLocationAvailabilityCriteria struct {
  2216  	// WebTestID - The Application Insights web test Id.
  2217  	WebTestID *string `json:"webTestId,omitempty"`
  2218  	// ComponentID - The Application Insights resource Id.
  2219  	ComponentID *string `json:"componentId,omitempty"`
  2220  	// FailedLocationCount - The number of failed locations.
  2221  	FailedLocationCount *float64 `json:"failedLocationCount,omitempty"`
  2222  	// AdditionalProperties - Unmatched properties from the message are deserialized this collection
  2223  	AdditionalProperties map[string]interface{} `json:""`
  2224  	// OdataType - Possible values include: 'OdataTypeMetricAlertCriteria', 'OdataTypeMicrosoftAzureMonitorSingleResourceMultipleMetricCriteria', 'OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria', 'OdataTypeMicrosoftAzureMonitorMultipleResourceMultipleMetricCriteria'
  2225  	OdataType OdataType `json:"odata.type,omitempty"`
  2226  }
  2227  
  2228  // MarshalJSON is the custom marshaler for WebtestLocationAvailabilityCriteria.
  2229  func (wlac WebtestLocationAvailabilityCriteria) MarshalJSON() ([]byte, error) {
  2230  	wlac.OdataType = OdataTypeMicrosoftAzureMonitorWebtestLocationAvailabilityCriteria
  2231  	objectMap := make(map[string]interface{})
  2232  	if wlac.WebTestID != nil {
  2233  		objectMap["webTestId"] = wlac.WebTestID
  2234  	}
  2235  	if wlac.ComponentID != nil {
  2236  		objectMap["componentId"] = wlac.ComponentID
  2237  	}
  2238  	if wlac.FailedLocationCount != nil {
  2239  		objectMap["failedLocationCount"] = wlac.FailedLocationCount
  2240  	}
  2241  	if wlac.OdataType != "" {
  2242  		objectMap["odata.type"] = wlac.OdataType
  2243  	}
  2244  	for k, v := range wlac.AdditionalProperties {
  2245  		objectMap[k] = v
  2246  	}
  2247  	return json.Marshal(objectMap)
  2248  }
  2249  
  2250  // AsAlertSingleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for WebtestLocationAvailabilityCriteria.
  2251  func (wlac WebtestLocationAvailabilityCriteria) AsAlertSingleResourceMultipleMetricCriteria() (*AlertSingleResourceMultipleMetricCriteria, bool) {
  2252  	return nil, false
  2253  }
  2254  
  2255  // AsWebtestLocationAvailabilityCriteria is the BasicAlertCriteria implementation for WebtestLocationAvailabilityCriteria.
  2256  func (wlac WebtestLocationAvailabilityCriteria) AsWebtestLocationAvailabilityCriteria() (*WebtestLocationAvailabilityCriteria, bool) {
  2257  	return &wlac, true
  2258  }
  2259  
  2260  // AsAlertMultipleResourceMultipleMetricCriteria is the BasicAlertCriteria implementation for WebtestLocationAvailabilityCriteria.
  2261  func (wlac WebtestLocationAvailabilityCriteria) AsAlertMultipleResourceMultipleMetricCriteria() (*AlertMultipleResourceMultipleMetricCriteria, bool) {
  2262  	return nil, false
  2263  }
  2264  
  2265  // AsAlertCriteria is the BasicAlertCriteria implementation for WebtestLocationAvailabilityCriteria.
  2266  func (wlac WebtestLocationAvailabilityCriteria) AsAlertCriteria() (*AlertCriteria, bool) {
  2267  	return nil, false
  2268  }
  2269  
  2270  // AsBasicAlertCriteria is the BasicAlertCriteria implementation for WebtestLocationAvailabilityCriteria.
  2271  func (wlac WebtestLocationAvailabilityCriteria) AsBasicAlertCriteria() (BasicAlertCriteria, bool) {
  2272  	return &wlac, true
  2273  }
  2274  
  2275  // UnmarshalJSON is the custom unmarshaler for WebtestLocationAvailabilityCriteria struct.
  2276  func (wlac *WebtestLocationAvailabilityCriteria) UnmarshalJSON(body []byte) error {
  2277  	var m map[string]*json.RawMessage
  2278  	err := json.Unmarshal(body, &m)
  2279  	if err != nil {
  2280  		return err
  2281  	}
  2282  	for k, v := range m {
  2283  		switch k {
  2284  		case "webTestId":
  2285  			if v != nil {
  2286  				var webTestID string
  2287  				err = json.Unmarshal(*v, &webTestID)
  2288  				if err != nil {
  2289  					return err
  2290  				}
  2291  				wlac.WebTestID = &webTestID
  2292  			}
  2293  		case "componentId":
  2294  			if v != nil {
  2295  				var componentID string
  2296  				err = json.Unmarshal(*v, &componentID)
  2297  				if err != nil {
  2298  					return err
  2299  				}
  2300  				wlac.ComponentID = &componentID
  2301  			}
  2302  		case "failedLocationCount":
  2303  			if v != nil {
  2304  				var failedLocationCount float64
  2305  				err = json.Unmarshal(*v, &failedLocationCount)
  2306  				if err != nil {
  2307  					return err
  2308  				}
  2309  				wlac.FailedLocationCount = &failedLocationCount
  2310  			}
  2311  		default:
  2312  			if v != nil {
  2313  				var additionalProperties interface{}
  2314  				err = json.Unmarshal(*v, &additionalProperties)
  2315  				if err != nil {
  2316  					return err
  2317  				}
  2318  				if wlac.AdditionalProperties == nil {
  2319  					wlac.AdditionalProperties = make(map[string]interface{})
  2320  				}
  2321  				wlac.AdditionalProperties[k] = additionalProperties
  2322  			}
  2323  		case "odata.type":
  2324  			if v != nil {
  2325  				var odataType OdataType
  2326  				err = json.Unmarshal(*v, &odataType)
  2327  				if err != nil {
  2328  					return err
  2329  				}
  2330  				wlac.OdataType = odataType
  2331  			}
  2332  		}
  2333  	}
  2334  
  2335  	return nil
  2336  }
  2337  

View as plain text