...

Source file src/github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2016-03-01-preview/monitorlegacy/models.go

Documentation: github.com/Azure/azure-sdk-for-go/services/preview/monitor/mgmt/2016-03-01-preview/monitorlegacy

     1  package monitorlegacy
     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/2016-03-01-preview/monitorlegacy"
    17  
    18  // AlertRule an alert rule.
    19  type AlertRule struct {
    20  	// Name - the name of the alert rule.
    21  	Name *string `json:"name,omitempty"`
    22  	// Description - the description of the alert rule that will be included in the alert email.
    23  	Description *string `json:"description,omitempty"`
    24  	// ProvisioningState - the provisioning state.
    25  	ProvisioningState *string `json:"provisioningState,omitempty"`
    26  	// IsEnabled - the flag that indicates whether the alert rule is enabled.
    27  	IsEnabled *bool `json:"isEnabled,omitempty"`
    28  	// Condition - the condition that results in the alert rule being activated.
    29  	Condition BasicRuleCondition `json:"condition,omitempty"`
    30  	// Action - action that is performed when the alert rule becomes active, and when an alert condition is resolved.
    31  	Action BasicRuleAction `json:"action,omitempty"`
    32  	// Actions - the array of actions that are performed when the alert rule becomes active, and when an alert condition is resolved.
    33  	Actions *[]BasicRuleAction `json:"actions,omitempty"`
    34  	// LastUpdatedTime - READ-ONLY; Last time the rule was updated in ISO8601 format.
    35  	LastUpdatedTime *date.Time `json:"lastUpdatedTime,omitempty"`
    36  }
    37  
    38  // MarshalJSON is the custom marshaler for AlertRule.
    39  func (ar AlertRule) MarshalJSON() ([]byte, error) {
    40  	objectMap := make(map[string]interface{})
    41  	if ar.Name != nil {
    42  		objectMap["name"] = ar.Name
    43  	}
    44  	if ar.Description != nil {
    45  		objectMap["description"] = ar.Description
    46  	}
    47  	if ar.ProvisioningState != nil {
    48  		objectMap["provisioningState"] = ar.ProvisioningState
    49  	}
    50  	if ar.IsEnabled != nil {
    51  		objectMap["isEnabled"] = ar.IsEnabled
    52  	}
    53  	objectMap["condition"] = ar.Condition
    54  	objectMap["action"] = ar.Action
    55  	if ar.Actions != nil {
    56  		objectMap["actions"] = ar.Actions
    57  	}
    58  	return json.Marshal(objectMap)
    59  }
    60  
    61  // UnmarshalJSON is the custom unmarshaler for AlertRule struct.
    62  func (ar *AlertRule) UnmarshalJSON(body []byte) error {
    63  	var m map[string]*json.RawMessage
    64  	err := json.Unmarshal(body, &m)
    65  	if err != nil {
    66  		return err
    67  	}
    68  	for k, v := range m {
    69  		switch k {
    70  		case "name":
    71  			if v != nil {
    72  				var name string
    73  				err = json.Unmarshal(*v, &name)
    74  				if err != nil {
    75  					return err
    76  				}
    77  				ar.Name = &name
    78  			}
    79  		case "description":
    80  			if v != nil {
    81  				var description string
    82  				err = json.Unmarshal(*v, &description)
    83  				if err != nil {
    84  					return err
    85  				}
    86  				ar.Description = &description
    87  			}
    88  		case "provisioningState":
    89  			if v != nil {
    90  				var provisioningState string
    91  				err = json.Unmarshal(*v, &provisioningState)
    92  				if err != nil {
    93  					return err
    94  				}
    95  				ar.ProvisioningState = &provisioningState
    96  			}
    97  		case "isEnabled":
    98  			if v != nil {
    99  				var isEnabled bool
   100  				err = json.Unmarshal(*v, &isEnabled)
   101  				if err != nil {
   102  					return err
   103  				}
   104  				ar.IsEnabled = &isEnabled
   105  			}
   106  		case "condition":
   107  			if v != nil {
   108  				condition, err := unmarshalBasicRuleCondition(*v)
   109  				if err != nil {
   110  					return err
   111  				}
   112  				ar.Condition = condition
   113  			}
   114  		case "action":
   115  			if v != nil {
   116  				action, err := unmarshalBasicRuleAction(*v)
   117  				if err != nil {
   118  					return err
   119  				}
   120  				ar.Action = action
   121  			}
   122  		case "actions":
   123  			if v != nil {
   124  				actions, err := unmarshalBasicRuleActionArray(*v)
   125  				if err != nil {
   126  					return err
   127  				}
   128  				ar.Actions = &actions
   129  			}
   130  		case "lastUpdatedTime":
   131  			if v != nil {
   132  				var lastUpdatedTime date.Time
   133  				err = json.Unmarshal(*v, &lastUpdatedTime)
   134  				if err != nil {
   135  					return err
   136  				}
   137  				ar.LastUpdatedTime = &lastUpdatedTime
   138  			}
   139  		}
   140  	}
   141  
   142  	return nil
   143  }
   144  
   145  // AlertRuleResource the alert rule resource.
   146  type AlertRuleResource struct {
   147  	autorest.Response `json:"-"`
   148  	// AlertRule - The alert rule properties of the resource.
   149  	*AlertRule `json:"properties,omitempty"`
   150  	// ID - READ-ONLY; Azure resource Id
   151  	ID *string `json:"id,omitempty"`
   152  	// Name - READ-ONLY; Azure resource name
   153  	Name *string `json:"name,omitempty"`
   154  	// Type - READ-ONLY; Azure resource type
   155  	Type *string `json:"type,omitempty"`
   156  	// Location - Resource location
   157  	Location *string `json:"location,omitempty"`
   158  	// Tags - Resource tags
   159  	Tags map[string]*string `json:"tags"`
   160  }
   161  
   162  // MarshalJSON is the custom marshaler for AlertRuleResource.
   163  func (arr AlertRuleResource) MarshalJSON() ([]byte, error) {
   164  	objectMap := make(map[string]interface{})
   165  	if arr.AlertRule != nil {
   166  		objectMap["properties"] = arr.AlertRule
   167  	}
   168  	if arr.Location != nil {
   169  		objectMap["location"] = arr.Location
   170  	}
   171  	if arr.Tags != nil {
   172  		objectMap["tags"] = arr.Tags
   173  	}
   174  	return json.Marshal(objectMap)
   175  }
   176  
   177  // UnmarshalJSON is the custom unmarshaler for AlertRuleResource struct.
   178  func (arr *AlertRuleResource) UnmarshalJSON(body []byte) error {
   179  	var m map[string]*json.RawMessage
   180  	err := json.Unmarshal(body, &m)
   181  	if err != nil {
   182  		return err
   183  	}
   184  	for k, v := range m {
   185  		switch k {
   186  		case "properties":
   187  			if v != nil {
   188  				var alertRule AlertRule
   189  				err = json.Unmarshal(*v, &alertRule)
   190  				if err != nil {
   191  					return err
   192  				}
   193  				arr.AlertRule = &alertRule
   194  			}
   195  		case "id":
   196  			if v != nil {
   197  				var ID string
   198  				err = json.Unmarshal(*v, &ID)
   199  				if err != nil {
   200  					return err
   201  				}
   202  				arr.ID = &ID
   203  			}
   204  		case "name":
   205  			if v != nil {
   206  				var name string
   207  				err = json.Unmarshal(*v, &name)
   208  				if err != nil {
   209  					return err
   210  				}
   211  				arr.Name = &name
   212  			}
   213  		case "type":
   214  			if v != nil {
   215  				var typeVar string
   216  				err = json.Unmarshal(*v, &typeVar)
   217  				if err != nil {
   218  					return err
   219  				}
   220  				arr.Type = &typeVar
   221  			}
   222  		case "location":
   223  			if v != nil {
   224  				var location string
   225  				err = json.Unmarshal(*v, &location)
   226  				if err != nil {
   227  					return err
   228  				}
   229  				arr.Location = &location
   230  			}
   231  		case "tags":
   232  			if v != nil {
   233  				var tags map[string]*string
   234  				err = json.Unmarshal(*v, &tags)
   235  				if err != nil {
   236  					return err
   237  				}
   238  				arr.Tags = tags
   239  			}
   240  		}
   241  	}
   242  
   243  	return nil
   244  }
   245  
   246  // AlertRuleResourceCollection represents a collection of alert rule resources.
   247  type AlertRuleResourceCollection struct {
   248  	autorest.Response `json:"-"`
   249  	// Value - the values for the alert rule resources.
   250  	Value *[]AlertRuleResource `json:"value,omitempty"`
   251  }
   252  
   253  // AlertRuleResourcePatch the alert rule object for patch operations.
   254  type AlertRuleResourcePatch struct {
   255  	// Tags - Resource tags
   256  	Tags map[string]*string `json:"tags"`
   257  	// AlertRule - The properties of an alert rule.
   258  	*AlertRule `json:"properties,omitempty"`
   259  }
   260  
   261  // MarshalJSON is the custom marshaler for AlertRuleResourcePatch.
   262  func (arrp AlertRuleResourcePatch) MarshalJSON() ([]byte, error) {
   263  	objectMap := make(map[string]interface{})
   264  	if arrp.Tags != nil {
   265  		objectMap["tags"] = arrp.Tags
   266  	}
   267  	if arrp.AlertRule != nil {
   268  		objectMap["properties"] = arrp.AlertRule
   269  	}
   270  	return json.Marshal(objectMap)
   271  }
   272  
   273  // UnmarshalJSON is the custom unmarshaler for AlertRuleResourcePatch struct.
   274  func (arrp *AlertRuleResourcePatch) UnmarshalJSON(body []byte) error {
   275  	var m map[string]*json.RawMessage
   276  	err := json.Unmarshal(body, &m)
   277  	if err != nil {
   278  		return err
   279  	}
   280  	for k, v := range m {
   281  		switch k {
   282  		case "tags":
   283  			if v != nil {
   284  				var tags map[string]*string
   285  				err = json.Unmarshal(*v, &tags)
   286  				if err != nil {
   287  					return err
   288  				}
   289  				arrp.Tags = tags
   290  			}
   291  		case "properties":
   292  			if v != nil {
   293  				var alertRule AlertRule
   294  				err = json.Unmarshal(*v, &alertRule)
   295  				if err != nil {
   296  					return err
   297  				}
   298  				arrp.AlertRule = &alertRule
   299  			}
   300  		}
   301  	}
   302  
   303  	return nil
   304  }
   305  
   306  // DataContainer information about a container with data for a given resource.
   307  type DataContainer struct {
   308  	// Workspace - Log Analytics workspace information.
   309  	Workspace *WorkspaceInfo `json:"workspace,omitempty"`
   310  }
   311  
   312  // Error error details.
   313  type Error struct {
   314  	// Code - Error code identifying the specific error.
   315  	Code *string `json:"code,omitempty"`
   316  	// Message - Error message in the caller's locale.
   317  	Message *string `json:"message,omitempty"`
   318  }
   319  
   320  // ErrorResponse describes the format of Error response.
   321  type ErrorResponse struct {
   322  	// Code - Error code
   323  	Code *string `json:"code,omitempty"`
   324  	// Message - Error message indicating why the operation failed.
   325  	Message *string `json:"message,omitempty"`
   326  }
   327  
   328  // EventCategoryCollection a collection of event categories. Currently possible values are: Administrative,
   329  // Security, ServiceHealth, Alert, Recommendation, Policy.
   330  type EventCategoryCollection struct {
   331  	autorest.Response `json:"-"`
   332  	// Value - the list that includes the Azure event categories.
   333  	Value *[]LocalizableString `json:"value,omitempty"`
   334  }
   335  
   336  // Incident an alert incident indicates the activation status of an alert rule.
   337  type Incident struct {
   338  	autorest.Response `json:"-"`
   339  	// Name - READ-ONLY; Incident name.
   340  	Name *string `json:"name,omitempty"`
   341  	// RuleName - READ-ONLY; Rule name that is associated with the incident.
   342  	RuleName *string `json:"ruleName,omitempty"`
   343  	// IsActive - READ-ONLY; A boolean to indicate whether the incident is active or resolved.
   344  	IsActive *bool `json:"isActive,omitempty"`
   345  	// ActivatedTime - READ-ONLY; The time at which the incident was activated in ISO8601 format.
   346  	ActivatedTime *date.Time `json:"activatedTime,omitempty"`
   347  	// ResolvedTime - READ-ONLY; The time at which the incident was resolved in ISO8601 format. If null, it means the incident is still active.
   348  	ResolvedTime *date.Time `json:"resolvedTime,omitempty"`
   349  }
   350  
   351  // MarshalJSON is the custom marshaler for Incident.
   352  func (i Incident) MarshalJSON() ([]byte, error) {
   353  	objectMap := make(map[string]interface{})
   354  	return json.Marshal(objectMap)
   355  }
   356  
   357  // IncidentListResult the List incidents operation response.
   358  type IncidentListResult struct {
   359  	autorest.Response `json:"-"`
   360  	// Value - the incident collection.
   361  	Value *[]Incident `json:"value,omitempty"`
   362  }
   363  
   364  // LocalizableString the localizable string class.
   365  type LocalizableString struct {
   366  	// Value - the invariant value.
   367  	Value *string `json:"value,omitempty"`
   368  	// LocalizedValue - the locale specific value.
   369  	LocalizedValue *string `json:"localizedValue,omitempty"`
   370  }
   371  
   372  // LocationThresholdRuleCondition a rule condition based on a certain number of locations failing.
   373  type LocationThresholdRuleCondition struct {
   374  	// WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day.
   375  	WindowSize *string `json:"windowSize,omitempty"`
   376  	// FailedLocationCount - the number of locations that must fail to activate the alert.
   377  	FailedLocationCount *int32 `json:"failedLocationCount,omitempty"`
   378  	// DataSource - the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource.
   379  	DataSource BasicRuleDataSource `json:"dataSource,omitempty"`
   380  	// OdataType - Possible values include: 'OdataTypeRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition'
   381  	OdataType OdataTypeBasicRuleCondition `json:"odata.type,omitempty"`
   382  }
   383  
   384  // MarshalJSON is the custom marshaler for LocationThresholdRuleCondition.
   385  func (ltrc LocationThresholdRuleCondition) MarshalJSON() ([]byte, error) {
   386  	ltrc.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition
   387  	objectMap := make(map[string]interface{})
   388  	if ltrc.WindowSize != nil {
   389  		objectMap["windowSize"] = ltrc.WindowSize
   390  	}
   391  	if ltrc.FailedLocationCount != nil {
   392  		objectMap["failedLocationCount"] = ltrc.FailedLocationCount
   393  	}
   394  	objectMap["dataSource"] = ltrc.DataSource
   395  	if ltrc.OdataType != "" {
   396  		objectMap["odata.type"] = ltrc.OdataType
   397  	}
   398  	return json.Marshal(objectMap)
   399  }
   400  
   401  // AsThresholdRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition.
   402  func (ltrc LocationThresholdRuleCondition) AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) {
   403  	return nil, false
   404  }
   405  
   406  // AsLocationThresholdRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition.
   407  func (ltrc LocationThresholdRuleCondition) AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) {
   408  	return &ltrc, true
   409  }
   410  
   411  // AsManagementEventRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition.
   412  func (ltrc LocationThresholdRuleCondition) AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) {
   413  	return nil, false
   414  }
   415  
   416  // AsRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition.
   417  func (ltrc LocationThresholdRuleCondition) AsRuleCondition() (*RuleCondition, bool) {
   418  	return nil, false
   419  }
   420  
   421  // AsBasicRuleCondition is the BasicRuleCondition implementation for LocationThresholdRuleCondition.
   422  func (ltrc LocationThresholdRuleCondition) AsBasicRuleCondition() (BasicRuleCondition, bool) {
   423  	return &ltrc, true
   424  }
   425  
   426  // UnmarshalJSON is the custom unmarshaler for LocationThresholdRuleCondition struct.
   427  func (ltrc *LocationThresholdRuleCondition) UnmarshalJSON(body []byte) error {
   428  	var m map[string]*json.RawMessage
   429  	err := json.Unmarshal(body, &m)
   430  	if err != nil {
   431  		return err
   432  	}
   433  	for k, v := range m {
   434  		switch k {
   435  		case "windowSize":
   436  			if v != nil {
   437  				var windowSize string
   438  				err = json.Unmarshal(*v, &windowSize)
   439  				if err != nil {
   440  					return err
   441  				}
   442  				ltrc.WindowSize = &windowSize
   443  			}
   444  		case "failedLocationCount":
   445  			if v != nil {
   446  				var failedLocationCount int32
   447  				err = json.Unmarshal(*v, &failedLocationCount)
   448  				if err != nil {
   449  					return err
   450  				}
   451  				ltrc.FailedLocationCount = &failedLocationCount
   452  			}
   453  		case "dataSource":
   454  			if v != nil {
   455  				dataSource, err := unmarshalBasicRuleDataSource(*v)
   456  				if err != nil {
   457  					return err
   458  				}
   459  				ltrc.DataSource = dataSource
   460  			}
   461  		case "odata.type":
   462  			if v != nil {
   463  				var odataType OdataTypeBasicRuleCondition
   464  				err = json.Unmarshal(*v, &odataType)
   465  				if err != nil {
   466  					return err
   467  				}
   468  				ltrc.OdataType = odataType
   469  			}
   470  		}
   471  	}
   472  
   473  	return nil
   474  }
   475  
   476  // LogProfileCollection represents a collection of log profiles.
   477  type LogProfileCollection struct {
   478  	autorest.Response `json:"-"`
   479  	// Value - the values of the log profiles.
   480  	Value *[]LogProfileResource `json:"value,omitempty"`
   481  }
   482  
   483  // LogProfileProperties the log profile properties.
   484  type LogProfileProperties struct {
   485  	// StorageAccountID - the resource id of the storage account to which you would like to send the Activity Log.
   486  	StorageAccountID *string `json:"storageAccountId,omitempty"`
   487  	// ServiceBusRuleID - The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming the Activity Log. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'.
   488  	ServiceBusRuleID *string `json:"serviceBusRuleId,omitempty"`
   489  	// Locations - List of regions for which Activity Log events should be stored or streamed. It is a comma separated list of valid ARM locations including the 'global' location.
   490  	Locations *[]string `json:"locations,omitempty"`
   491  	// Categories - the categories of the logs. These categories are created as is convenient to the user. Some values are: 'Write', 'Delete', and/or 'Action.'
   492  	Categories *[]string `json:"categories,omitempty"`
   493  	// RetentionPolicy - the retention policy for the events in the log.
   494  	RetentionPolicy *RetentionPolicy `json:"retentionPolicy,omitempty"`
   495  }
   496  
   497  // LogProfileResource the log profile resource.
   498  type LogProfileResource struct {
   499  	autorest.Response `json:"-"`
   500  	// LogProfileProperties - The log profile properties of the resource.
   501  	*LogProfileProperties `json:"properties,omitempty"`
   502  	// ID - READ-ONLY; Azure resource Id
   503  	ID *string `json:"id,omitempty"`
   504  	// Name - READ-ONLY; Azure resource name
   505  	Name *string `json:"name,omitempty"`
   506  	// Type - READ-ONLY; Azure resource type
   507  	Type *string `json:"type,omitempty"`
   508  	// Location - Resource location
   509  	Location *string `json:"location,omitempty"`
   510  	// Tags - Resource tags
   511  	Tags map[string]*string `json:"tags"`
   512  }
   513  
   514  // MarshalJSON is the custom marshaler for LogProfileResource.
   515  func (lpr LogProfileResource) MarshalJSON() ([]byte, error) {
   516  	objectMap := make(map[string]interface{})
   517  	if lpr.LogProfileProperties != nil {
   518  		objectMap["properties"] = lpr.LogProfileProperties
   519  	}
   520  	if lpr.Location != nil {
   521  		objectMap["location"] = lpr.Location
   522  	}
   523  	if lpr.Tags != nil {
   524  		objectMap["tags"] = lpr.Tags
   525  	}
   526  	return json.Marshal(objectMap)
   527  }
   528  
   529  // UnmarshalJSON is the custom unmarshaler for LogProfileResource struct.
   530  func (lpr *LogProfileResource) UnmarshalJSON(body []byte) error {
   531  	var m map[string]*json.RawMessage
   532  	err := json.Unmarshal(body, &m)
   533  	if err != nil {
   534  		return err
   535  	}
   536  	for k, v := range m {
   537  		switch k {
   538  		case "properties":
   539  			if v != nil {
   540  				var logProfileProperties LogProfileProperties
   541  				err = json.Unmarshal(*v, &logProfileProperties)
   542  				if err != nil {
   543  					return err
   544  				}
   545  				lpr.LogProfileProperties = &logProfileProperties
   546  			}
   547  		case "id":
   548  			if v != nil {
   549  				var ID string
   550  				err = json.Unmarshal(*v, &ID)
   551  				if err != nil {
   552  					return err
   553  				}
   554  				lpr.ID = &ID
   555  			}
   556  		case "name":
   557  			if v != nil {
   558  				var name string
   559  				err = json.Unmarshal(*v, &name)
   560  				if err != nil {
   561  					return err
   562  				}
   563  				lpr.Name = &name
   564  			}
   565  		case "type":
   566  			if v != nil {
   567  				var typeVar string
   568  				err = json.Unmarshal(*v, &typeVar)
   569  				if err != nil {
   570  					return err
   571  				}
   572  				lpr.Type = &typeVar
   573  			}
   574  		case "location":
   575  			if v != nil {
   576  				var location string
   577  				err = json.Unmarshal(*v, &location)
   578  				if err != nil {
   579  					return err
   580  				}
   581  				lpr.Location = &location
   582  			}
   583  		case "tags":
   584  			if v != nil {
   585  				var tags map[string]*string
   586  				err = json.Unmarshal(*v, &tags)
   587  				if err != nil {
   588  					return err
   589  				}
   590  				lpr.Tags = tags
   591  			}
   592  		}
   593  	}
   594  
   595  	return nil
   596  }
   597  
   598  // LogProfileResourcePatch the log profile resource for patch operations.
   599  type LogProfileResourcePatch struct {
   600  	// Tags - Resource tags
   601  	Tags map[string]*string `json:"tags"`
   602  	// LogProfileProperties - The log profile properties for an update operation.
   603  	*LogProfileProperties `json:"properties,omitempty"`
   604  }
   605  
   606  // MarshalJSON is the custom marshaler for LogProfileResourcePatch.
   607  func (lprp LogProfileResourcePatch) MarshalJSON() ([]byte, error) {
   608  	objectMap := make(map[string]interface{})
   609  	if lprp.Tags != nil {
   610  		objectMap["tags"] = lprp.Tags
   611  	}
   612  	if lprp.LogProfileProperties != nil {
   613  		objectMap["properties"] = lprp.LogProfileProperties
   614  	}
   615  	return json.Marshal(objectMap)
   616  }
   617  
   618  // UnmarshalJSON is the custom unmarshaler for LogProfileResourcePatch struct.
   619  func (lprp *LogProfileResourcePatch) UnmarshalJSON(body []byte) error {
   620  	var m map[string]*json.RawMessage
   621  	err := json.Unmarshal(body, &m)
   622  	if err != nil {
   623  		return err
   624  	}
   625  	for k, v := range m {
   626  		switch k {
   627  		case "tags":
   628  			if v != nil {
   629  				var tags map[string]*string
   630  				err = json.Unmarshal(*v, &tags)
   631  				if err != nil {
   632  					return err
   633  				}
   634  				lprp.Tags = tags
   635  			}
   636  		case "properties":
   637  			if v != nil {
   638  				var logProfileProperties LogProfileProperties
   639  				err = json.Unmarshal(*v, &logProfileProperties)
   640  				if err != nil {
   641  					return err
   642  				}
   643  				lprp.LogProfileProperties = &logProfileProperties
   644  			}
   645  		}
   646  	}
   647  
   648  	return nil
   649  }
   650  
   651  // ManagementEventAggregationCondition how the data that is collected should be combined over time.
   652  type ManagementEventAggregationCondition struct {
   653  	// Operator - the condition operator. Possible values include: 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual'
   654  	Operator ConditionOperator `json:"operator,omitempty"`
   655  	// Threshold - The threshold value that activates the alert.
   656  	Threshold *float64 `json:"threshold,omitempty"`
   657  	// WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day.
   658  	WindowSize *string `json:"windowSize,omitempty"`
   659  }
   660  
   661  // ManagementEventRuleCondition a management event rule condition.
   662  type ManagementEventRuleCondition struct {
   663  	// Aggregation - How the data that is collected should be combined over time and when the alert is activated. Note that for management event alerts aggregation is optional – if it is not provided then any event will cause the alert to activate.
   664  	Aggregation *ManagementEventAggregationCondition `json:"aggregation,omitempty"`
   665  	// DataSource - the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource.
   666  	DataSource BasicRuleDataSource `json:"dataSource,omitempty"`
   667  	// OdataType - Possible values include: 'OdataTypeRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition'
   668  	OdataType OdataTypeBasicRuleCondition `json:"odata.type,omitempty"`
   669  }
   670  
   671  // MarshalJSON is the custom marshaler for ManagementEventRuleCondition.
   672  func (merc ManagementEventRuleCondition) MarshalJSON() ([]byte, error) {
   673  	merc.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition
   674  	objectMap := make(map[string]interface{})
   675  	if merc.Aggregation != nil {
   676  		objectMap["aggregation"] = merc.Aggregation
   677  	}
   678  	objectMap["dataSource"] = merc.DataSource
   679  	if merc.OdataType != "" {
   680  		objectMap["odata.type"] = merc.OdataType
   681  	}
   682  	return json.Marshal(objectMap)
   683  }
   684  
   685  // AsThresholdRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition.
   686  func (merc ManagementEventRuleCondition) AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) {
   687  	return nil, false
   688  }
   689  
   690  // AsLocationThresholdRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition.
   691  func (merc ManagementEventRuleCondition) AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) {
   692  	return nil, false
   693  }
   694  
   695  // AsManagementEventRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition.
   696  func (merc ManagementEventRuleCondition) AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) {
   697  	return &merc, true
   698  }
   699  
   700  // AsRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition.
   701  func (merc ManagementEventRuleCondition) AsRuleCondition() (*RuleCondition, bool) {
   702  	return nil, false
   703  }
   704  
   705  // AsBasicRuleCondition is the BasicRuleCondition implementation for ManagementEventRuleCondition.
   706  func (merc ManagementEventRuleCondition) AsBasicRuleCondition() (BasicRuleCondition, bool) {
   707  	return &merc, true
   708  }
   709  
   710  // UnmarshalJSON is the custom unmarshaler for ManagementEventRuleCondition struct.
   711  func (merc *ManagementEventRuleCondition) UnmarshalJSON(body []byte) error {
   712  	var m map[string]*json.RawMessage
   713  	err := json.Unmarshal(body, &m)
   714  	if err != nil {
   715  		return err
   716  	}
   717  	for k, v := range m {
   718  		switch k {
   719  		case "aggregation":
   720  			if v != nil {
   721  				var aggregation ManagementEventAggregationCondition
   722  				err = json.Unmarshal(*v, &aggregation)
   723  				if err != nil {
   724  					return err
   725  				}
   726  				merc.Aggregation = &aggregation
   727  			}
   728  		case "dataSource":
   729  			if v != nil {
   730  				dataSource, err := unmarshalBasicRuleDataSource(*v)
   731  				if err != nil {
   732  					return err
   733  				}
   734  				merc.DataSource = dataSource
   735  			}
   736  		case "odata.type":
   737  			if v != nil {
   738  				var odataType OdataTypeBasicRuleCondition
   739  				err = json.Unmarshal(*v, &odataType)
   740  				if err != nil {
   741  					return err
   742  				}
   743  				merc.OdataType = odataType
   744  			}
   745  		}
   746  	}
   747  
   748  	return nil
   749  }
   750  
   751  // ProxyResource an azure resource object
   752  type ProxyResource struct {
   753  	// ID - READ-ONLY; Azure resource Id
   754  	ID *string `json:"id,omitempty"`
   755  	// Name - READ-ONLY; Azure resource name
   756  	Name *string `json:"name,omitempty"`
   757  	// Type - READ-ONLY; Azure resource type
   758  	Type *string `json:"type,omitempty"`
   759  }
   760  
   761  // MarshalJSON is the custom marshaler for ProxyResource.
   762  func (pr ProxyResource) MarshalJSON() ([]byte, error) {
   763  	objectMap := make(map[string]interface{})
   764  	return json.Marshal(objectMap)
   765  }
   766  
   767  // Resource an azure resource object
   768  type Resource struct {
   769  	// ID - READ-ONLY; Azure resource Id
   770  	ID *string `json:"id,omitempty"`
   771  	// Name - READ-ONLY; Azure resource name
   772  	Name *string `json:"name,omitempty"`
   773  	// Type - READ-ONLY; Azure resource type
   774  	Type *string `json:"type,omitempty"`
   775  	// Location - Resource location
   776  	Location *string `json:"location,omitempty"`
   777  	// Tags - Resource tags
   778  	Tags map[string]*string `json:"tags"`
   779  }
   780  
   781  // MarshalJSON is the custom marshaler for Resource.
   782  func (r Resource) MarshalJSON() ([]byte, error) {
   783  	objectMap := make(map[string]interface{})
   784  	if r.Location != nil {
   785  		objectMap["location"] = r.Location
   786  	}
   787  	if r.Tags != nil {
   788  		objectMap["tags"] = r.Tags
   789  	}
   790  	return json.Marshal(objectMap)
   791  }
   792  
   793  // ResponseWithError an error response from the API.
   794  type ResponseWithError struct {
   795  	// Error - Error information.
   796  	Error *Error `json:"error,omitempty"`
   797  }
   798  
   799  // RetentionPolicy specifies the retention policy for the log.
   800  type RetentionPolicy struct {
   801  	// Enabled - a value indicating whether the retention policy is enabled.
   802  	Enabled *bool `json:"enabled,omitempty"`
   803  	// Days - the number of days for the retention in days. A value of 0 will retain the events indefinitely.
   804  	Days *int32 `json:"days,omitempty"`
   805  }
   806  
   807  // BasicRuleAction the action that is performed when the alert rule becomes active, and when an alert condition is
   808  // resolved.
   809  type BasicRuleAction interface {
   810  	AsRuleEmailAction() (*RuleEmailAction, bool)
   811  	AsRuleWebhookAction() (*RuleWebhookAction, bool)
   812  	AsRuleAction() (*RuleAction, bool)
   813  }
   814  
   815  // RuleAction the action that is performed when the alert rule becomes active, and when an alert condition is
   816  // resolved.
   817  type RuleAction struct {
   818  	// OdataType - Possible values include: 'OdataTypeRuleAction', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction'
   819  	OdataType OdataTypeBasicRuleAction `json:"odata.type,omitempty"`
   820  }
   821  
   822  func unmarshalBasicRuleAction(body []byte) (BasicRuleAction, error) {
   823  	var m map[string]interface{}
   824  	err := json.Unmarshal(body, &m)
   825  	if err != nil {
   826  		return nil, err
   827  	}
   828  
   829  	switch m["odata.type"] {
   830  	case string(OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction):
   831  		var rea RuleEmailAction
   832  		err := json.Unmarshal(body, &rea)
   833  		return rea, err
   834  	case string(OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction):
   835  		var rwa RuleWebhookAction
   836  		err := json.Unmarshal(body, &rwa)
   837  		return rwa, err
   838  	default:
   839  		var ra RuleAction
   840  		err := json.Unmarshal(body, &ra)
   841  		return ra, err
   842  	}
   843  }
   844  func unmarshalBasicRuleActionArray(body []byte) ([]BasicRuleAction, error) {
   845  	var rawMessages []*json.RawMessage
   846  	err := json.Unmarshal(body, &rawMessages)
   847  	if err != nil {
   848  		return nil, err
   849  	}
   850  
   851  	raArray := make([]BasicRuleAction, len(rawMessages))
   852  
   853  	for index, rawMessage := range rawMessages {
   854  		ra, err := unmarshalBasicRuleAction(*rawMessage)
   855  		if err != nil {
   856  			return nil, err
   857  		}
   858  		raArray[index] = ra
   859  	}
   860  	return raArray, nil
   861  }
   862  
   863  // MarshalJSON is the custom marshaler for RuleAction.
   864  func (ra RuleAction) MarshalJSON() ([]byte, error) {
   865  	ra.OdataType = OdataTypeRuleAction
   866  	objectMap := make(map[string]interface{})
   867  	if ra.OdataType != "" {
   868  		objectMap["odata.type"] = ra.OdataType
   869  	}
   870  	return json.Marshal(objectMap)
   871  }
   872  
   873  // AsRuleEmailAction is the BasicRuleAction implementation for RuleAction.
   874  func (ra RuleAction) AsRuleEmailAction() (*RuleEmailAction, bool) {
   875  	return nil, false
   876  }
   877  
   878  // AsRuleWebhookAction is the BasicRuleAction implementation for RuleAction.
   879  func (ra RuleAction) AsRuleWebhookAction() (*RuleWebhookAction, bool) {
   880  	return nil, false
   881  }
   882  
   883  // AsRuleAction is the BasicRuleAction implementation for RuleAction.
   884  func (ra RuleAction) AsRuleAction() (*RuleAction, bool) {
   885  	return &ra, true
   886  }
   887  
   888  // AsBasicRuleAction is the BasicRuleAction implementation for RuleAction.
   889  func (ra RuleAction) AsBasicRuleAction() (BasicRuleAction, bool) {
   890  	return &ra, true
   891  }
   892  
   893  // BasicRuleCondition the condition that results in the alert rule being activated.
   894  type BasicRuleCondition interface {
   895  	AsThresholdRuleCondition() (*ThresholdRuleCondition, bool)
   896  	AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool)
   897  	AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool)
   898  	AsRuleCondition() (*RuleCondition, bool)
   899  }
   900  
   901  // RuleCondition the condition that results in the alert rule being activated.
   902  type RuleCondition struct {
   903  	// DataSource - the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource.
   904  	DataSource BasicRuleDataSource `json:"dataSource,omitempty"`
   905  	// OdataType - Possible values include: 'OdataTypeRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition'
   906  	OdataType OdataTypeBasicRuleCondition `json:"odata.type,omitempty"`
   907  }
   908  
   909  func unmarshalBasicRuleCondition(body []byte) (BasicRuleCondition, error) {
   910  	var m map[string]interface{}
   911  	err := json.Unmarshal(body, &m)
   912  	if err != nil {
   913  		return nil, err
   914  	}
   915  
   916  	switch m["odata.type"] {
   917  	case string(OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition):
   918  		var trc ThresholdRuleCondition
   919  		err := json.Unmarshal(body, &trc)
   920  		return trc, err
   921  	case string(OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition):
   922  		var ltrc LocationThresholdRuleCondition
   923  		err := json.Unmarshal(body, &ltrc)
   924  		return ltrc, err
   925  	case string(OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition):
   926  		var merc ManagementEventRuleCondition
   927  		err := json.Unmarshal(body, &merc)
   928  		return merc, err
   929  	default:
   930  		var rc RuleCondition
   931  		err := json.Unmarshal(body, &rc)
   932  		return rc, err
   933  	}
   934  }
   935  func unmarshalBasicRuleConditionArray(body []byte) ([]BasicRuleCondition, error) {
   936  	var rawMessages []*json.RawMessage
   937  	err := json.Unmarshal(body, &rawMessages)
   938  	if err != nil {
   939  		return nil, err
   940  	}
   941  
   942  	rcArray := make([]BasicRuleCondition, len(rawMessages))
   943  
   944  	for index, rawMessage := range rawMessages {
   945  		rc, err := unmarshalBasicRuleCondition(*rawMessage)
   946  		if err != nil {
   947  			return nil, err
   948  		}
   949  		rcArray[index] = rc
   950  	}
   951  	return rcArray, nil
   952  }
   953  
   954  // MarshalJSON is the custom marshaler for RuleCondition.
   955  func (rc RuleCondition) MarshalJSON() ([]byte, error) {
   956  	rc.OdataType = OdataTypeRuleCondition
   957  	objectMap := make(map[string]interface{})
   958  	objectMap["dataSource"] = rc.DataSource
   959  	if rc.OdataType != "" {
   960  		objectMap["odata.type"] = rc.OdataType
   961  	}
   962  	return json.Marshal(objectMap)
   963  }
   964  
   965  // AsThresholdRuleCondition is the BasicRuleCondition implementation for RuleCondition.
   966  func (rc RuleCondition) AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) {
   967  	return nil, false
   968  }
   969  
   970  // AsLocationThresholdRuleCondition is the BasicRuleCondition implementation for RuleCondition.
   971  func (rc RuleCondition) AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) {
   972  	return nil, false
   973  }
   974  
   975  // AsManagementEventRuleCondition is the BasicRuleCondition implementation for RuleCondition.
   976  func (rc RuleCondition) AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) {
   977  	return nil, false
   978  }
   979  
   980  // AsRuleCondition is the BasicRuleCondition implementation for RuleCondition.
   981  func (rc RuleCondition) AsRuleCondition() (*RuleCondition, bool) {
   982  	return &rc, true
   983  }
   984  
   985  // AsBasicRuleCondition is the BasicRuleCondition implementation for RuleCondition.
   986  func (rc RuleCondition) AsBasicRuleCondition() (BasicRuleCondition, bool) {
   987  	return &rc, true
   988  }
   989  
   990  // UnmarshalJSON is the custom unmarshaler for RuleCondition struct.
   991  func (rc *RuleCondition) UnmarshalJSON(body []byte) error {
   992  	var m map[string]*json.RawMessage
   993  	err := json.Unmarshal(body, &m)
   994  	if err != nil {
   995  		return err
   996  	}
   997  	for k, v := range m {
   998  		switch k {
   999  		case "dataSource":
  1000  			if v != nil {
  1001  				dataSource, err := unmarshalBasicRuleDataSource(*v)
  1002  				if err != nil {
  1003  					return err
  1004  				}
  1005  				rc.DataSource = dataSource
  1006  			}
  1007  		case "odata.type":
  1008  			if v != nil {
  1009  				var odataType OdataTypeBasicRuleCondition
  1010  				err = json.Unmarshal(*v, &odataType)
  1011  				if err != nil {
  1012  					return err
  1013  				}
  1014  				rc.OdataType = odataType
  1015  			}
  1016  		}
  1017  	}
  1018  
  1019  	return nil
  1020  }
  1021  
  1022  // BasicRuleDataSource the resource from which the rule collects its data.
  1023  type BasicRuleDataSource interface {
  1024  	AsRuleMetricDataSource() (*RuleMetricDataSource, bool)
  1025  	AsRuleManagementEventDataSource() (*RuleManagementEventDataSource, bool)
  1026  	AsRuleDataSource() (*RuleDataSource, bool)
  1027  }
  1028  
  1029  // RuleDataSource the resource from which the rule collects its data.
  1030  type RuleDataSource struct {
  1031  	// ResourceURI - the resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule.
  1032  	ResourceURI *string `json:"resourceUri,omitempty"`
  1033  	// LegacyResourceID - the legacy resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule.
  1034  	LegacyResourceID *string `json:"legacyResourceId,omitempty"`
  1035  	// ResourceLocation - the location of the resource.
  1036  	ResourceLocation *string `json:"resourceLocation,omitempty"`
  1037  	// MetricNamespace - the namespace of the metric.
  1038  	MetricNamespace *string `json:"metricNamespace,omitempty"`
  1039  	// OdataType - Possible values include: 'OdataTypeRuleDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource'
  1040  	OdataType OdataType `json:"odata.type,omitempty"`
  1041  }
  1042  
  1043  func unmarshalBasicRuleDataSource(body []byte) (BasicRuleDataSource, error) {
  1044  	var m map[string]interface{}
  1045  	err := json.Unmarshal(body, &m)
  1046  	if err != nil {
  1047  		return nil, err
  1048  	}
  1049  
  1050  	switch m["odata.type"] {
  1051  	case string(OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource):
  1052  		var rmds RuleMetricDataSource
  1053  		err := json.Unmarshal(body, &rmds)
  1054  		return rmds, err
  1055  	case string(OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource):
  1056  		var rmeds RuleManagementEventDataSource
  1057  		err := json.Unmarshal(body, &rmeds)
  1058  		return rmeds, err
  1059  	default:
  1060  		var rds RuleDataSource
  1061  		err := json.Unmarshal(body, &rds)
  1062  		return rds, err
  1063  	}
  1064  }
  1065  func unmarshalBasicRuleDataSourceArray(body []byte) ([]BasicRuleDataSource, error) {
  1066  	var rawMessages []*json.RawMessage
  1067  	err := json.Unmarshal(body, &rawMessages)
  1068  	if err != nil {
  1069  		return nil, err
  1070  	}
  1071  
  1072  	rdsArray := make([]BasicRuleDataSource, len(rawMessages))
  1073  
  1074  	for index, rawMessage := range rawMessages {
  1075  		rds, err := unmarshalBasicRuleDataSource(*rawMessage)
  1076  		if err != nil {
  1077  			return nil, err
  1078  		}
  1079  		rdsArray[index] = rds
  1080  	}
  1081  	return rdsArray, nil
  1082  }
  1083  
  1084  // MarshalJSON is the custom marshaler for RuleDataSource.
  1085  func (rds RuleDataSource) MarshalJSON() ([]byte, error) {
  1086  	rds.OdataType = OdataTypeRuleDataSource
  1087  	objectMap := make(map[string]interface{})
  1088  	if rds.ResourceURI != nil {
  1089  		objectMap["resourceUri"] = rds.ResourceURI
  1090  	}
  1091  	if rds.LegacyResourceID != nil {
  1092  		objectMap["legacyResourceId"] = rds.LegacyResourceID
  1093  	}
  1094  	if rds.ResourceLocation != nil {
  1095  		objectMap["resourceLocation"] = rds.ResourceLocation
  1096  	}
  1097  	if rds.MetricNamespace != nil {
  1098  		objectMap["metricNamespace"] = rds.MetricNamespace
  1099  	}
  1100  	if rds.OdataType != "" {
  1101  		objectMap["odata.type"] = rds.OdataType
  1102  	}
  1103  	return json.Marshal(objectMap)
  1104  }
  1105  
  1106  // AsRuleMetricDataSource is the BasicRuleDataSource implementation for RuleDataSource.
  1107  func (rds RuleDataSource) AsRuleMetricDataSource() (*RuleMetricDataSource, bool) {
  1108  	return nil, false
  1109  }
  1110  
  1111  // AsRuleManagementEventDataSource is the BasicRuleDataSource implementation for RuleDataSource.
  1112  func (rds RuleDataSource) AsRuleManagementEventDataSource() (*RuleManagementEventDataSource, bool) {
  1113  	return nil, false
  1114  }
  1115  
  1116  // AsRuleDataSource is the BasicRuleDataSource implementation for RuleDataSource.
  1117  func (rds RuleDataSource) AsRuleDataSource() (*RuleDataSource, bool) {
  1118  	return &rds, true
  1119  }
  1120  
  1121  // AsBasicRuleDataSource is the BasicRuleDataSource implementation for RuleDataSource.
  1122  func (rds RuleDataSource) AsBasicRuleDataSource() (BasicRuleDataSource, bool) {
  1123  	return &rds, true
  1124  }
  1125  
  1126  // RuleEmailAction specifies the action to send email when the rule condition is evaluated. The
  1127  // discriminator is always RuleEmailAction in this case.
  1128  type RuleEmailAction struct {
  1129  	// SendToServiceOwners - Whether the administrators (service and co-administrators) of the service should be notified when the alert is activated.
  1130  	SendToServiceOwners *bool `json:"sendToServiceOwners,omitempty"`
  1131  	// CustomEmails - the list of administrator's custom email addresses to notify of the activation of the alert.
  1132  	CustomEmails *[]string `json:"customEmails,omitempty"`
  1133  	// OdataType - Possible values include: 'OdataTypeRuleAction', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction'
  1134  	OdataType OdataTypeBasicRuleAction `json:"odata.type,omitempty"`
  1135  }
  1136  
  1137  // MarshalJSON is the custom marshaler for RuleEmailAction.
  1138  func (rea RuleEmailAction) MarshalJSON() ([]byte, error) {
  1139  	rea.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction
  1140  	objectMap := make(map[string]interface{})
  1141  	if rea.SendToServiceOwners != nil {
  1142  		objectMap["sendToServiceOwners"] = rea.SendToServiceOwners
  1143  	}
  1144  	if rea.CustomEmails != nil {
  1145  		objectMap["customEmails"] = rea.CustomEmails
  1146  	}
  1147  	if rea.OdataType != "" {
  1148  		objectMap["odata.type"] = rea.OdataType
  1149  	}
  1150  	return json.Marshal(objectMap)
  1151  }
  1152  
  1153  // AsRuleEmailAction is the BasicRuleAction implementation for RuleEmailAction.
  1154  func (rea RuleEmailAction) AsRuleEmailAction() (*RuleEmailAction, bool) {
  1155  	return &rea, true
  1156  }
  1157  
  1158  // AsRuleWebhookAction is the BasicRuleAction implementation for RuleEmailAction.
  1159  func (rea RuleEmailAction) AsRuleWebhookAction() (*RuleWebhookAction, bool) {
  1160  	return nil, false
  1161  }
  1162  
  1163  // AsRuleAction is the BasicRuleAction implementation for RuleEmailAction.
  1164  func (rea RuleEmailAction) AsRuleAction() (*RuleAction, bool) {
  1165  	return nil, false
  1166  }
  1167  
  1168  // AsBasicRuleAction is the BasicRuleAction implementation for RuleEmailAction.
  1169  func (rea RuleEmailAction) AsBasicRuleAction() (BasicRuleAction, bool) {
  1170  	return &rea, true
  1171  }
  1172  
  1173  // RuleManagementEventClaimsDataSource the claims for a rule management event data source.
  1174  type RuleManagementEventClaimsDataSource struct {
  1175  	// EmailAddress - the email address.
  1176  	EmailAddress *string `json:"emailAddress,omitempty"`
  1177  }
  1178  
  1179  // RuleManagementEventDataSource a rule management event data source. The discriminator fields is always
  1180  // RuleManagementEventDataSource in this case.
  1181  type RuleManagementEventDataSource struct {
  1182  	// EventName - the event name.
  1183  	EventName *string `json:"eventName,omitempty"`
  1184  	// EventSource - the event source.
  1185  	EventSource *string `json:"eventSource,omitempty"`
  1186  	// Level - the level.
  1187  	Level *string `json:"level,omitempty"`
  1188  	// OperationName - The name of the operation that should be checked for. If no name is provided, any operation will match.
  1189  	OperationName *string `json:"operationName,omitempty"`
  1190  	// ResourceGroupName - the resource group name.
  1191  	ResourceGroupName *string `json:"resourceGroupName,omitempty"`
  1192  	// ResourceProviderName - the resource provider name.
  1193  	ResourceProviderName *string `json:"resourceProviderName,omitempty"`
  1194  	// Status - The status of the operation that should be checked for. If no status is provided, any status will match.
  1195  	Status *string `json:"status,omitempty"`
  1196  	// SubStatus - the substatus.
  1197  	SubStatus *string `json:"subStatus,omitempty"`
  1198  	// Claims - the claims.
  1199  	Claims *RuleManagementEventClaimsDataSource `json:"claims,omitempty"`
  1200  	// ResourceURI - the resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule.
  1201  	ResourceURI *string `json:"resourceUri,omitempty"`
  1202  	// LegacyResourceID - the legacy resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule.
  1203  	LegacyResourceID *string `json:"legacyResourceId,omitempty"`
  1204  	// ResourceLocation - the location of the resource.
  1205  	ResourceLocation *string `json:"resourceLocation,omitempty"`
  1206  	// MetricNamespace - the namespace of the metric.
  1207  	MetricNamespace *string `json:"metricNamespace,omitempty"`
  1208  	// OdataType - Possible values include: 'OdataTypeRuleDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource'
  1209  	OdataType OdataType `json:"odata.type,omitempty"`
  1210  }
  1211  
  1212  // MarshalJSON is the custom marshaler for RuleManagementEventDataSource.
  1213  func (rmeds RuleManagementEventDataSource) MarshalJSON() ([]byte, error) {
  1214  	rmeds.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource
  1215  	objectMap := make(map[string]interface{})
  1216  	if rmeds.EventName != nil {
  1217  		objectMap["eventName"] = rmeds.EventName
  1218  	}
  1219  	if rmeds.EventSource != nil {
  1220  		objectMap["eventSource"] = rmeds.EventSource
  1221  	}
  1222  	if rmeds.Level != nil {
  1223  		objectMap["level"] = rmeds.Level
  1224  	}
  1225  	if rmeds.OperationName != nil {
  1226  		objectMap["operationName"] = rmeds.OperationName
  1227  	}
  1228  	if rmeds.ResourceGroupName != nil {
  1229  		objectMap["resourceGroupName"] = rmeds.ResourceGroupName
  1230  	}
  1231  	if rmeds.ResourceProviderName != nil {
  1232  		objectMap["resourceProviderName"] = rmeds.ResourceProviderName
  1233  	}
  1234  	if rmeds.Status != nil {
  1235  		objectMap["status"] = rmeds.Status
  1236  	}
  1237  	if rmeds.SubStatus != nil {
  1238  		objectMap["subStatus"] = rmeds.SubStatus
  1239  	}
  1240  	if rmeds.Claims != nil {
  1241  		objectMap["claims"] = rmeds.Claims
  1242  	}
  1243  	if rmeds.ResourceURI != nil {
  1244  		objectMap["resourceUri"] = rmeds.ResourceURI
  1245  	}
  1246  	if rmeds.LegacyResourceID != nil {
  1247  		objectMap["legacyResourceId"] = rmeds.LegacyResourceID
  1248  	}
  1249  	if rmeds.ResourceLocation != nil {
  1250  		objectMap["resourceLocation"] = rmeds.ResourceLocation
  1251  	}
  1252  	if rmeds.MetricNamespace != nil {
  1253  		objectMap["metricNamespace"] = rmeds.MetricNamespace
  1254  	}
  1255  	if rmeds.OdataType != "" {
  1256  		objectMap["odata.type"] = rmeds.OdataType
  1257  	}
  1258  	return json.Marshal(objectMap)
  1259  }
  1260  
  1261  // AsRuleMetricDataSource is the BasicRuleDataSource implementation for RuleManagementEventDataSource.
  1262  func (rmeds RuleManagementEventDataSource) AsRuleMetricDataSource() (*RuleMetricDataSource, bool) {
  1263  	return nil, false
  1264  }
  1265  
  1266  // AsRuleManagementEventDataSource is the BasicRuleDataSource implementation for RuleManagementEventDataSource.
  1267  func (rmeds RuleManagementEventDataSource) AsRuleManagementEventDataSource() (*RuleManagementEventDataSource, bool) {
  1268  	return &rmeds, true
  1269  }
  1270  
  1271  // AsRuleDataSource is the BasicRuleDataSource implementation for RuleManagementEventDataSource.
  1272  func (rmeds RuleManagementEventDataSource) AsRuleDataSource() (*RuleDataSource, bool) {
  1273  	return nil, false
  1274  }
  1275  
  1276  // AsBasicRuleDataSource is the BasicRuleDataSource implementation for RuleManagementEventDataSource.
  1277  func (rmeds RuleManagementEventDataSource) AsBasicRuleDataSource() (BasicRuleDataSource, bool) {
  1278  	return &rmeds, true
  1279  }
  1280  
  1281  // RuleMetricDataSource a rule metric data source. The discriminator value is always RuleMetricDataSource
  1282  // in this case.
  1283  type RuleMetricDataSource struct {
  1284  	// MetricName - the name of the metric that defines what the rule monitors.
  1285  	MetricName *string `json:"metricName,omitempty"`
  1286  	// ResourceURI - the resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule.
  1287  	ResourceURI *string `json:"resourceUri,omitempty"`
  1288  	// LegacyResourceID - the legacy resource identifier of the resource the rule monitors. **NOTE**: this property cannot be updated for an existing rule.
  1289  	LegacyResourceID *string `json:"legacyResourceId,omitempty"`
  1290  	// ResourceLocation - the location of the resource.
  1291  	ResourceLocation *string `json:"resourceLocation,omitempty"`
  1292  	// MetricNamespace - the namespace of the metric.
  1293  	MetricNamespace *string `json:"metricNamespace,omitempty"`
  1294  	// OdataType - Possible values include: 'OdataTypeRuleDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleManagementEventDataSource'
  1295  	OdataType OdataType `json:"odata.type,omitempty"`
  1296  }
  1297  
  1298  // MarshalJSON is the custom marshaler for RuleMetricDataSource.
  1299  func (rmds RuleMetricDataSource) MarshalJSON() ([]byte, error) {
  1300  	rmds.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsRuleMetricDataSource
  1301  	objectMap := make(map[string]interface{})
  1302  	if rmds.MetricName != nil {
  1303  		objectMap["metricName"] = rmds.MetricName
  1304  	}
  1305  	if rmds.ResourceURI != nil {
  1306  		objectMap["resourceUri"] = rmds.ResourceURI
  1307  	}
  1308  	if rmds.LegacyResourceID != nil {
  1309  		objectMap["legacyResourceId"] = rmds.LegacyResourceID
  1310  	}
  1311  	if rmds.ResourceLocation != nil {
  1312  		objectMap["resourceLocation"] = rmds.ResourceLocation
  1313  	}
  1314  	if rmds.MetricNamespace != nil {
  1315  		objectMap["metricNamespace"] = rmds.MetricNamespace
  1316  	}
  1317  	if rmds.OdataType != "" {
  1318  		objectMap["odata.type"] = rmds.OdataType
  1319  	}
  1320  	return json.Marshal(objectMap)
  1321  }
  1322  
  1323  // AsRuleMetricDataSource is the BasicRuleDataSource implementation for RuleMetricDataSource.
  1324  func (rmds RuleMetricDataSource) AsRuleMetricDataSource() (*RuleMetricDataSource, bool) {
  1325  	return &rmds, true
  1326  }
  1327  
  1328  // AsRuleManagementEventDataSource is the BasicRuleDataSource implementation for RuleMetricDataSource.
  1329  func (rmds RuleMetricDataSource) AsRuleManagementEventDataSource() (*RuleManagementEventDataSource, bool) {
  1330  	return nil, false
  1331  }
  1332  
  1333  // AsRuleDataSource is the BasicRuleDataSource implementation for RuleMetricDataSource.
  1334  func (rmds RuleMetricDataSource) AsRuleDataSource() (*RuleDataSource, bool) {
  1335  	return nil, false
  1336  }
  1337  
  1338  // AsBasicRuleDataSource is the BasicRuleDataSource implementation for RuleMetricDataSource.
  1339  func (rmds RuleMetricDataSource) AsBasicRuleDataSource() (BasicRuleDataSource, bool) {
  1340  	return &rmds, true
  1341  }
  1342  
  1343  // RuleWebhookAction specifies the action to post to service when the rule condition is evaluated. The
  1344  // discriminator is always RuleWebhookAction in this case.
  1345  type RuleWebhookAction struct {
  1346  	// ServiceURI - the service uri to Post the notification when the alert activates or resolves.
  1347  	ServiceURI *string `json:"serviceUri,omitempty"`
  1348  	// Properties - the dictionary of custom properties to include with the post operation. These data are appended to the webhook payload.
  1349  	Properties map[string]*string `json:"properties"`
  1350  	// OdataType - Possible values include: 'OdataTypeRuleAction', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleEmailAction', 'OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction'
  1351  	OdataType OdataTypeBasicRuleAction `json:"odata.type,omitempty"`
  1352  }
  1353  
  1354  // MarshalJSON is the custom marshaler for RuleWebhookAction.
  1355  func (rwa RuleWebhookAction) MarshalJSON() ([]byte, error) {
  1356  	rwa.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsRuleWebhookAction
  1357  	objectMap := make(map[string]interface{})
  1358  	if rwa.ServiceURI != nil {
  1359  		objectMap["serviceUri"] = rwa.ServiceURI
  1360  	}
  1361  	if rwa.Properties != nil {
  1362  		objectMap["properties"] = rwa.Properties
  1363  	}
  1364  	if rwa.OdataType != "" {
  1365  		objectMap["odata.type"] = rwa.OdataType
  1366  	}
  1367  	return json.Marshal(objectMap)
  1368  }
  1369  
  1370  // AsRuleEmailAction is the BasicRuleAction implementation for RuleWebhookAction.
  1371  func (rwa RuleWebhookAction) AsRuleEmailAction() (*RuleEmailAction, bool) {
  1372  	return nil, false
  1373  }
  1374  
  1375  // AsRuleWebhookAction is the BasicRuleAction implementation for RuleWebhookAction.
  1376  func (rwa RuleWebhookAction) AsRuleWebhookAction() (*RuleWebhookAction, bool) {
  1377  	return &rwa, true
  1378  }
  1379  
  1380  // AsRuleAction is the BasicRuleAction implementation for RuleWebhookAction.
  1381  func (rwa RuleWebhookAction) AsRuleAction() (*RuleAction, bool) {
  1382  	return nil, false
  1383  }
  1384  
  1385  // AsBasicRuleAction is the BasicRuleAction implementation for RuleWebhookAction.
  1386  func (rwa RuleWebhookAction) AsBasicRuleAction() (BasicRuleAction, bool) {
  1387  	return &rwa, true
  1388  }
  1389  
  1390  // ThresholdRuleCondition a rule condition based on a metric crossing a threshold.
  1391  type ThresholdRuleCondition struct {
  1392  	// Operator - the operator used to compare the data and the threshold. Possible values include: 'GreaterThan', 'GreaterThanOrEqual', 'LessThan', 'LessThanOrEqual'
  1393  	Operator ConditionOperator `json:"operator,omitempty"`
  1394  	// Threshold - the threshold value that activates the alert.
  1395  	Threshold *float64 `json:"threshold,omitempty"`
  1396  	// WindowSize - the period of time (in ISO 8601 duration format) that is used to monitor alert activity based on the threshold. If specified then it must be between 5 minutes and 1 day.
  1397  	WindowSize *string `json:"windowSize,omitempty"`
  1398  	// TimeAggregation - the time aggregation operator. How the data that are collected should be combined over time. The default value is the PrimaryAggregationType of the Metric. Possible values include: 'Average', 'Minimum', 'Maximum', 'Total', 'Last'
  1399  	TimeAggregation TimeAggregationOperator `json:"timeAggregation,omitempty"`
  1400  	// DataSource - the resource from which the rule collects its data. For this type dataSource will always be of type RuleMetricDataSource.
  1401  	DataSource BasicRuleDataSource `json:"dataSource,omitempty"`
  1402  	// OdataType - Possible values include: 'OdataTypeRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsLocationThresholdRuleCondition', 'OdataTypeMicrosoftAzureManagementInsightsModelsManagementEventRuleCondition'
  1403  	OdataType OdataTypeBasicRuleCondition `json:"odata.type,omitempty"`
  1404  }
  1405  
  1406  // MarshalJSON is the custom marshaler for ThresholdRuleCondition.
  1407  func (trc ThresholdRuleCondition) MarshalJSON() ([]byte, error) {
  1408  	trc.OdataType = OdataTypeMicrosoftAzureManagementInsightsModelsThresholdRuleCondition
  1409  	objectMap := make(map[string]interface{})
  1410  	if trc.Operator != "" {
  1411  		objectMap["operator"] = trc.Operator
  1412  	}
  1413  	if trc.Threshold != nil {
  1414  		objectMap["threshold"] = trc.Threshold
  1415  	}
  1416  	if trc.WindowSize != nil {
  1417  		objectMap["windowSize"] = trc.WindowSize
  1418  	}
  1419  	if trc.TimeAggregation != "" {
  1420  		objectMap["timeAggregation"] = trc.TimeAggregation
  1421  	}
  1422  	objectMap["dataSource"] = trc.DataSource
  1423  	if trc.OdataType != "" {
  1424  		objectMap["odata.type"] = trc.OdataType
  1425  	}
  1426  	return json.Marshal(objectMap)
  1427  }
  1428  
  1429  // AsThresholdRuleCondition is the BasicRuleCondition implementation for ThresholdRuleCondition.
  1430  func (trc ThresholdRuleCondition) AsThresholdRuleCondition() (*ThresholdRuleCondition, bool) {
  1431  	return &trc, true
  1432  }
  1433  
  1434  // AsLocationThresholdRuleCondition is the BasicRuleCondition implementation for ThresholdRuleCondition.
  1435  func (trc ThresholdRuleCondition) AsLocationThresholdRuleCondition() (*LocationThresholdRuleCondition, bool) {
  1436  	return nil, false
  1437  }
  1438  
  1439  // AsManagementEventRuleCondition is the BasicRuleCondition implementation for ThresholdRuleCondition.
  1440  func (trc ThresholdRuleCondition) AsManagementEventRuleCondition() (*ManagementEventRuleCondition, bool) {
  1441  	return nil, false
  1442  }
  1443  
  1444  // AsRuleCondition is the BasicRuleCondition implementation for ThresholdRuleCondition.
  1445  func (trc ThresholdRuleCondition) AsRuleCondition() (*RuleCondition, bool) {
  1446  	return nil, false
  1447  }
  1448  
  1449  // AsBasicRuleCondition is the BasicRuleCondition implementation for ThresholdRuleCondition.
  1450  func (trc ThresholdRuleCondition) AsBasicRuleCondition() (BasicRuleCondition, bool) {
  1451  	return &trc, true
  1452  }
  1453  
  1454  // UnmarshalJSON is the custom unmarshaler for ThresholdRuleCondition struct.
  1455  func (trc *ThresholdRuleCondition) UnmarshalJSON(body []byte) error {
  1456  	var m map[string]*json.RawMessage
  1457  	err := json.Unmarshal(body, &m)
  1458  	if err != nil {
  1459  		return err
  1460  	}
  1461  	for k, v := range m {
  1462  		switch k {
  1463  		case "operator":
  1464  			if v != nil {
  1465  				var operator ConditionOperator
  1466  				err = json.Unmarshal(*v, &operator)
  1467  				if err != nil {
  1468  					return err
  1469  				}
  1470  				trc.Operator = operator
  1471  			}
  1472  		case "threshold":
  1473  			if v != nil {
  1474  				var threshold float64
  1475  				err = json.Unmarshal(*v, &threshold)
  1476  				if err != nil {
  1477  					return err
  1478  				}
  1479  				trc.Threshold = &threshold
  1480  			}
  1481  		case "windowSize":
  1482  			if v != nil {
  1483  				var windowSize string
  1484  				err = json.Unmarshal(*v, &windowSize)
  1485  				if err != nil {
  1486  					return err
  1487  				}
  1488  				trc.WindowSize = &windowSize
  1489  			}
  1490  		case "timeAggregation":
  1491  			if v != nil {
  1492  				var timeAggregation TimeAggregationOperator
  1493  				err = json.Unmarshal(*v, &timeAggregation)
  1494  				if err != nil {
  1495  					return err
  1496  				}
  1497  				trc.TimeAggregation = timeAggregation
  1498  			}
  1499  		case "dataSource":
  1500  			if v != nil {
  1501  				dataSource, err := unmarshalBasicRuleDataSource(*v)
  1502  				if err != nil {
  1503  					return err
  1504  				}
  1505  				trc.DataSource = dataSource
  1506  			}
  1507  		case "odata.type":
  1508  			if v != nil {
  1509  				var odataType OdataTypeBasicRuleCondition
  1510  				err = json.Unmarshal(*v, &odataType)
  1511  				if err != nil {
  1512  					return err
  1513  				}
  1514  				trc.OdataType = odataType
  1515  			}
  1516  		}
  1517  	}
  1518  
  1519  	return nil
  1520  }
  1521  
  1522  // VMInsightsOnboardingStatus VM Insights onboarding status for a resource.
  1523  type VMInsightsOnboardingStatus struct {
  1524  	autorest.Response `json:"-"`
  1525  	// VMInsightsOnboardingStatusProperties - Resource properties.
  1526  	*VMInsightsOnboardingStatusProperties `json:"properties,omitempty"`
  1527  	// ID - READ-ONLY; Azure resource Id
  1528  	ID *string `json:"id,omitempty"`
  1529  	// Name - READ-ONLY; Azure resource name
  1530  	Name *string `json:"name,omitempty"`
  1531  	// Type - READ-ONLY; Azure resource type
  1532  	Type *string `json:"type,omitempty"`
  1533  }
  1534  
  1535  // MarshalJSON is the custom marshaler for VMInsightsOnboardingStatus.
  1536  func (vios VMInsightsOnboardingStatus) MarshalJSON() ([]byte, error) {
  1537  	objectMap := make(map[string]interface{})
  1538  	if vios.VMInsightsOnboardingStatusProperties != nil {
  1539  		objectMap["properties"] = vios.VMInsightsOnboardingStatusProperties
  1540  	}
  1541  	return json.Marshal(objectMap)
  1542  }
  1543  
  1544  // UnmarshalJSON is the custom unmarshaler for VMInsightsOnboardingStatus struct.
  1545  func (vios *VMInsightsOnboardingStatus) UnmarshalJSON(body []byte) error {
  1546  	var m map[string]*json.RawMessage
  1547  	err := json.Unmarshal(body, &m)
  1548  	if err != nil {
  1549  		return err
  1550  	}
  1551  	for k, v := range m {
  1552  		switch k {
  1553  		case "properties":
  1554  			if v != nil {
  1555  				var VMInsightsOnboardingStatusProperties VMInsightsOnboardingStatusProperties
  1556  				err = json.Unmarshal(*v, &VMInsightsOnboardingStatusProperties)
  1557  				if err != nil {
  1558  					return err
  1559  				}
  1560  				vios.VMInsightsOnboardingStatusProperties = &VMInsightsOnboardingStatusProperties
  1561  			}
  1562  		case "id":
  1563  			if v != nil {
  1564  				var ID string
  1565  				err = json.Unmarshal(*v, &ID)
  1566  				if err != nil {
  1567  					return err
  1568  				}
  1569  				vios.ID = &ID
  1570  			}
  1571  		case "name":
  1572  			if v != nil {
  1573  				var name string
  1574  				err = json.Unmarshal(*v, &name)
  1575  				if err != nil {
  1576  					return err
  1577  				}
  1578  				vios.Name = &name
  1579  			}
  1580  		case "type":
  1581  			if v != nil {
  1582  				var typeVar string
  1583  				err = json.Unmarshal(*v, &typeVar)
  1584  				if err != nil {
  1585  					return err
  1586  				}
  1587  				vios.Type = &typeVar
  1588  			}
  1589  		}
  1590  	}
  1591  
  1592  	return nil
  1593  }
  1594  
  1595  // VMInsightsOnboardingStatusProperties resource properties.
  1596  type VMInsightsOnboardingStatusProperties struct {
  1597  	// ResourceID - Azure Resource Manager identifier of the resource whose onboarding status is being represented.
  1598  	ResourceID *string `json:"resourceId,omitempty"`
  1599  	// OnboardingStatus - The onboarding status for the resource. Note that, a higher level scope, e.g., resource group or subscription, is considered onboarded if at least one resource under it is onboarded. Possible values include: 'Onboarded', 'NotOnboarded', 'Unknown'
  1600  	OnboardingStatus OnboardingStatus `json:"onboardingStatus,omitempty"`
  1601  	// DataStatus - The status of VM Insights data from the resource. When reported as `present` the data array will contain information about the data containers to which data for the specified resource is being routed. Possible values include: 'Present', 'NotPresent'
  1602  	DataStatus DataStatus `json:"dataStatus,omitempty"`
  1603  	// Data - Containers that currently store VM Insights data for the specified resource.
  1604  	Data *[]DataContainer `json:"data,omitempty"`
  1605  }
  1606  
  1607  // WorkspaceInfo information about a Log Analytics Workspace.
  1608  type WorkspaceInfo struct {
  1609  	// ID - Azure Resource Manager identifier of the Log Analytics Workspace.
  1610  	ID *string `json:"id,omitempty"`
  1611  	// Location - Location of the Log Analytics workspace.
  1612  	Location *string `json:"location,omitempty"`
  1613  	// WorkspaceInfoProperties - Resource properties.
  1614  	*WorkspaceInfoProperties `json:"properties,omitempty"`
  1615  }
  1616  
  1617  // MarshalJSON is the custom marshaler for WorkspaceInfo.
  1618  func (wi WorkspaceInfo) MarshalJSON() ([]byte, error) {
  1619  	objectMap := make(map[string]interface{})
  1620  	if wi.ID != nil {
  1621  		objectMap["id"] = wi.ID
  1622  	}
  1623  	if wi.Location != nil {
  1624  		objectMap["location"] = wi.Location
  1625  	}
  1626  	if wi.WorkspaceInfoProperties != nil {
  1627  		objectMap["properties"] = wi.WorkspaceInfoProperties
  1628  	}
  1629  	return json.Marshal(objectMap)
  1630  }
  1631  
  1632  // UnmarshalJSON is the custom unmarshaler for WorkspaceInfo struct.
  1633  func (wi *WorkspaceInfo) UnmarshalJSON(body []byte) error {
  1634  	var m map[string]*json.RawMessage
  1635  	err := json.Unmarshal(body, &m)
  1636  	if err != nil {
  1637  		return err
  1638  	}
  1639  	for k, v := range m {
  1640  		switch k {
  1641  		case "id":
  1642  			if v != nil {
  1643  				var ID string
  1644  				err = json.Unmarshal(*v, &ID)
  1645  				if err != nil {
  1646  					return err
  1647  				}
  1648  				wi.ID = &ID
  1649  			}
  1650  		case "location":
  1651  			if v != nil {
  1652  				var location string
  1653  				err = json.Unmarshal(*v, &location)
  1654  				if err != nil {
  1655  					return err
  1656  				}
  1657  				wi.Location = &location
  1658  			}
  1659  		case "properties":
  1660  			if v != nil {
  1661  				var workspaceInfoProperties WorkspaceInfoProperties
  1662  				err = json.Unmarshal(*v, &workspaceInfoProperties)
  1663  				if err != nil {
  1664  					return err
  1665  				}
  1666  				wi.WorkspaceInfoProperties = &workspaceInfoProperties
  1667  			}
  1668  		}
  1669  	}
  1670  
  1671  	return nil
  1672  }
  1673  
  1674  // WorkspaceInfoProperties resource properties.
  1675  type WorkspaceInfoProperties struct {
  1676  	// CustomerID - Log Analytics workspace identifier.
  1677  	CustomerID *string `json:"customerId,omitempty"`
  1678  }
  1679  

View as plain text