// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT.

package armcloudhealth

import (
	"encoding/json"
	"fmt"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime/datetime"
	"reflect"
	"time"
)

// MarshalJSON implements the json.Marshaller interface for type AddDataAnnotationRequest.
func (a AddDataAnnotationRequest) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "annotationDetails", a.AnnotationDetails)
	populate(objectMap, "description", a.Description)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type AddDataAnnotationRequest.
func (a *AddDataAnnotationRequest) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "annotationDetails":
			err = unpopulate(val, "AnnotationDetails", &a.AnnotationDetails)
			delete(rawMsg, key)
		case "description":
			err = unpopulate(val, "Description", &a.Description)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type AlertConfiguration.
func (a AlertConfiguration) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "actionGroupIds", a.ActionGroupIDs)
	populate(objectMap, "description", a.Description)
	populate(objectMap, "severity", a.Severity)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type AlertConfiguration.
func (a *AlertConfiguration) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "actionGroupIds":
			err = unpopulate(val, "ActionGroupIDs", &a.ActionGroupIDs)
			delete(rawMsg, key)
		case "description":
			err = unpopulate(val, "Description", &a.Description)
			delete(rawMsg, key)
		case "severity":
			err = unpopulate(val, "Severity", &a.Severity)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type ApplicationInsightsTopologySpecification.
func (a ApplicationInsightsTopologySpecification) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "applicationInsightsResourceId", a.ApplicationInsightsResourceID)
	objectMap["kind"] = DiscoveryRuleKindApplicationInsightsTopology
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type ApplicationInsightsTopologySpecification.
func (a *ApplicationInsightsTopologySpecification) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "applicationInsightsResourceId":
			err = unpopulate(val, "ApplicationInsightsResourceID", &a.ApplicationInsightsResourceID)
			delete(rawMsg, key)
		case "kind":
			err = unpopulate(val, "Kind", &a.Kind)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type AuthenticationSetting.
func (a AuthenticationSetting) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "id", a.ID)
	populate(objectMap, "name", a.Name)
	populate(objectMap, "properties", a.Properties)
	populate(objectMap, "systemData", a.SystemData)
	populate(objectMap, "type", a.Type)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type AuthenticationSetting.
func (a *AuthenticationSetting) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "id":
			err = unpopulate(val, "ID", &a.ID)
			delete(rawMsg, key)
		case "name":
			err = unpopulate(val, "Name", &a.Name)
			delete(rawMsg, key)
		case "properties":
			a.Properties, err = unmarshalAuthenticationSettingPropertiesClassification(val)
			delete(rawMsg, key)
		case "systemData":
			err = unpopulate(val, "SystemData", &a.SystemData)
			delete(rawMsg, key)
		case "type":
			err = unpopulate(val, "Type", &a.Type)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type AuthenticationSettingListResult.
func (a AuthenticationSettingListResult) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "nextLink", a.NextLink)
	populate(objectMap, "value", a.Value)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type AuthenticationSettingListResult.
func (a *AuthenticationSettingListResult) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "nextLink":
			err = unpopulate(val, "NextLink", &a.NextLink)
			delete(rawMsg, key)
		case "value":
			err = unpopulate(val, "Value", &a.Value)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type AuthenticationSettingProperties.
func (a AuthenticationSettingProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "authenticationKind", a.AuthenticationKind)
	populate(objectMap, "displayName", a.DisplayName)
	populate(objectMap, "provisioningState", a.ProvisioningState)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type AuthenticationSettingProperties.
func (a *AuthenticationSettingProperties) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "authenticationKind":
			err = unpopulate(val, "AuthenticationKind", &a.AuthenticationKind)
			delete(rawMsg, key)
		case "displayName":
			err = unpopulate(val, "DisplayName", &a.DisplayName)
			delete(rawMsg, key)
		case "provisioningState":
			err = unpopulate(val, "ProvisioningState", &a.ProvisioningState)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type AzureMonitorWorkspaceSignals.
func (a AzureMonitorWorkspaceSignals) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "authenticationSetting", a.AuthenticationSetting)
	populate(objectMap, "azureMonitorWorkspaceResourceId", a.AzureMonitorWorkspaceResourceID)
	populate(objectMap, "signals", a.Signals)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type AzureMonitorWorkspaceSignals.
func (a *AzureMonitorWorkspaceSignals) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "authenticationSetting":
			err = unpopulate(val, "AuthenticationSetting", &a.AuthenticationSetting)
			delete(rawMsg, key)
		case "azureMonitorWorkspaceResourceId":
			err = unpopulate(val, "AzureMonitorWorkspaceResourceID", &a.AzureMonitorWorkspaceResourceID)
			delete(rawMsg, key)
		case "signals":
			err = unpopulate(val, "Signals", &a.Signals)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type AzureResourceHealthSignal.
func (a AzureResourceHealthSignal) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "enabled", a.Enabled)
	populate(objectMap, "signalName", a.SignalName)
	populate(objectMap, "status", a.Status)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type AzureResourceHealthSignal.
func (a *AzureResourceHealthSignal) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "enabled":
			err = unpopulate(val, "Enabled", &a.Enabled)
			delete(rawMsg, key)
		case "signalName":
			err = unpopulate(val, "SignalName", &a.SignalName)
			delete(rawMsg, key)
		case "status":
			err = unpopulate(val, "Status", &a.Status)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type AzureResourceHealthSignalStatus.
func (a AzureResourceHealthSignalStatus) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "additionalContext", a.AdditionalContext)
	populateTime[datetime.RFC3339](objectMap, "availabilityReportedTime", a.AvailabilityReportedTime)
	populate(objectMap, "availabilityState", a.AvailabilityState)
	populate(objectMap, "category", a.Category)
	populate(objectMap, "detailedStatus", a.DetailedStatus)
	populate(objectMap, "error", a.Error)
	populate(objectMap, "healthState", a.HealthState)
	populate(objectMap, "reasonChronicity", a.ReasonChronicity)
	populate(objectMap, "reasonType", a.ReasonType)
	populateTime[datetime.RFC3339](objectMap, "reportedAt", a.ReportedAt)
	populate(objectMap, "summary", a.Summary)
	populate(objectMap, "value", a.Value)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type AzureResourceHealthSignalStatus.
func (a *AzureResourceHealthSignalStatus) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "additionalContext":
			err = unpopulate(val, "AdditionalContext", &a.AdditionalContext)
			delete(rawMsg, key)
		case "availabilityReportedTime":
			err = unpopulateTime[datetime.RFC3339](val, "AvailabilityReportedTime", &a.AvailabilityReportedTime)
			delete(rawMsg, key)
		case "availabilityState":
			err = unpopulate(val, "AvailabilityState", &a.AvailabilityState)
			delete(rawMsg, key)
		case "category":
			err = unpopulate(val, "Category", &a.Category)
			delete(rawMsg, key)
		case "detailedStatus":
			err = unpopulate(val, "DetailedStatus", &a.DetailedStatus)
			delete(rawMsg, key)
		case "error":
			err = unpopulate(val, "Error", &a.Error)
			delete(rawMsg, key)
		case "healthState":
			err = unpopulate(val, "HealthState", &a.HealthState)
			delete(rawMsg, key)
		case "reasonChronicity":
			err = unpopulate(val, "ReasonChronicity", &a.ReasonChronicity)
			delete(rawMsg, key)
		case "reasonType":
			err = unpopulate(val, "ReasonType", &a.ReasonType)
			delete(rawMsg, key)
		case "reportedAt":
			err = unpopulateTime[datetime.RFC3339](val, "ReportedAt", &a.ReportedAt)
			delete(rawMsg, key)
		case "summary":
			err = unpopulate(val, "Summary", &a.Summary)
			delete(rawMsg, key)
		case "value":
			err = unpopulate(val, "Value", &a.Value)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type AzureResourceSignal.
func (a AzureResourceSignal) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "aggregationType", a.AggregationType)
	populate(objectMap, "dataUnit", a.DataUnit)
	populate(objectMap, "dimensionFilter", a.DimensionFilter)
	populate(objectMap, "displayName", a.DisplayName)
	populate(objectMap, "evaluationRules", a.EvaluationRules)
	populate(objectMap, "metricName", a.MetricName)
	populate(objectMap, "metricNamespace", a.MetricNamespace)
	populate(objectMap, "name", a.Name)
	populate(objectMap, "refreshInterval", a.RefreshInterval)
	populate(objectMap, "signalDefinitionName", a.SignalDefinitionName)
	objectMap["signalKind"] = SignalKindAzureResourceMetric
	populate(objectMap, "status", a.Status)
	populate(objectMap, "timeGrain", a.TimeGrain)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type AzureResourceSignal.
func (a *AzureResourceSignal) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "aggregationType":
			err = unpopulate(val, "AggregationType", &a.AggregationType)
			delete(rawMsg, key)
		case "dataUnit":
			err = unpopulate(val, "DataUnit", &a.DataUnit)
			delete(rawMsg, key)
		case "dimensionFilter":
			err = unpopulate(val, "DimensionFilter", &a.DimensionFilter)
			delete(rawMsg, key)
		case "displayName":
			err = unpopulate(val, "DisplayName", &a.DisplayName)
			delete(rawMsg, key)
		case "evaluationRules":
			err = unpopulate(val, "EvaluationRules", &a.EvaluationRules)
			delete(rawMsg, key)
		case "metricName":
			err = unpopulate(val, "MetricName", &a.MetricName)
			delete(rawMsg, key)
		case "metricNamespace":
			err = unpopulate(val, "MetricNamespace", &a.MetricNamespace)
			delete(rawMsg, key)
		case "name":
			err = unpopulate(val, "Name", &a.Name)
			delete(rawMsg, key)
		case "refreshInterval":
			err = unpopulate(val, "RefreshInterval", &a.RefreshInterval)
			delete(rawMsg, key)
		case "signalDefinitionName":
			err = unpopulate(val, "SignalDefinitionName", &a.SignalDefinitionName)
			delete(rawMsg, key)
		case "signalKind":
			err = unpopulate(val, "SignalKind", &a.SignalKind)
			delete(rawMsg, key)
		case "status":
			err = unpopulate(val, "Status", &a.Status)
			delete(rawMsg, key)
		case "timeGrain":
			err = unpopulate(val, "TimeGrain", &a.TimeGrain)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type AzureResourceSignals.
func (a AzureResourceSignals) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "authenticationSetting", a.AuthenticationSetting)
	populate(objectMap, "azureResourceId", a.AzureResourceID)
	populate(objectMap, "azureResourceKind", a.AzureResourceKind)
	populate(objectMap, "resourceHealth", a.ResourceHealth)
	populate(objectMap, "signals", a.Signals)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type AzureResourceSignals.
func (a *AzureResourceSignals) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "authenticationSetting":
			err = unpopulate(val, "AuthenticationSetting", &a.AuthenticationSetting)
			delete(rawMsg, key)
		case "azureResourceId":
			err = unpopulate(val, "AzureResourceID", &a.AzureResourceID)
			delete(rawMsg, key)
		case "azureResourceKind":
			err = unpopulate(val, "AzureResourceKind", &a.AzureResourceKind)
			delete(rawMsg, key)
		case "resourceHealth":
			err = unpopulate(val, "ResourceHealth", &a.ResourceHealth)
			delete(rawMsg, key)
		case "signals":
			err = unpopulate(val, "Signals", &a.Signals)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", a, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type DataAnnotation.
func (d DataAnnotation) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "annotationDetails", d.AnnotationDetails)
	populate(objectMap, "annotationId", d.AnnotationID)
	populateTime[datetime.RFC3339](objectMap, "createdAt", d.CreatedAt)
	populate(objectMap, "description", d.Description)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type DataAnnotation.
func (d *DataAnnotation) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", d, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "annotationDetails":
			err = unpopulate(val, "AnnotationDetails", &d.AnnotationDetails)
			delete(rawMsg, key)
		case "annotationId":
			err = unpopulate(val, "AnnotationID", &d.AnnotationID)
			delete(rawMsg, key)
		case "createdAt":
			err = unpopulateTime[datetime.RFC3339](val, "CreatedAt", &d.CreatedAt)
			delete(rawMsg, key)
		case "description":
			err = unpopulate(val, "Description", &d.Description)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", d, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type DependenciesSignalGroupV2.
func (d DependenciesSignalGroupV2) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "aggregationType", d.AggregationType)
	populate(objectMap, "degradedThreshold", d.DegradedThreshold)
	populate(objectMap, "ignoreUnknown", d.IgnoreUnknown)
	populate(objectMap, "unhealthyThreshold", d.UnhealthyThreshold)
	populate(objectMap, "unit", d.Unit)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type DependenciesSignalGroupV2.
func (d *DependenciesSignalGroupV2) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", d, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "aggregationType":
			err = unpopulate(val, "AggregationType", &d.AggregationType)
			delete(rawMsg, key)
		case "degradedThreshold":
			err = unpopulate(val, "DegradedThreshold", &d.DegradedThreshold)
			delete(rawMsg, key)
		case "ignoreUnknown":
			err = unpopulate(val, "IgnoreUnknown", &d.IgnoreUnknown)
			delete(rawMsg, key)
		case "unhealthyThreshold":
			err = unpopulate(val, "UnhealthyThreshold", &d.UnhealthyThreshold)
			delete(rawMsg, key)
		case "unit":
			err = unpopulate(val, "Unit", &d.Unit)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", d, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type DiscoveryError.
func (d DiscoveryError) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "context", d.Context)
	populate(objectMap, "message", d.Message)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type DiscoveryError.
func (d *DiscoveryError) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", d, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "context":
			err = unpopulate(val, "Context", &d.Context)
			delete(rawMsg, key)
		case "message":
			err = unpopulate(val, "Message", &d.Message)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", d, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type DiscoveryRule.
func (d DiscoveryRule) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "id", d.ID)
	populate(objectMap, "name", d.Name)
	populate(objectMap, "properties", d.Properties)
	populate(objectMap, "systemData", d.SystemData)
	populate(objectMap, "type", d.Type)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type DiscoveryRule.
func (d *DiscoveryRule) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", d, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "id":
			err = unpopulate(val, "ID", &d.ID)
			delete(rawMsg, key)
		case "name":
			err = unpopulate(val, "Name", &d.Name)
			delete(rawMsg, key)
		case "properties":
			err = unpopulate(val, "Properties", &d.Properties)
			delete(rawMsg, key)
		case "systemData":
			err = unpopulate(val, "SystemData", &d.SystemData)
			delete(rawMsg, key)
		case "type":
			err = unpopulate(val, "Type", &d.Type)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", d, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type DiscoveryRuleListResult.
func (d DiscoveryRuleListResult) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "nextLink", d.NextLink)
	populate(objectMap, "value", d.Value)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type DiscoveryRuleListResult.
func (d *DiscoveryRuleListResult) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", d, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "nextLink":
			err = unpopulate(val, "NextLink", &d.NextLink)
			delete(rawMsg, key)
		case "value":
			err = unpopulate(val, "Value", &d.Value)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", d, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type DiscoveryRuleProperties.
func (d DiscoveryRuleProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "addRecommendedSignals", d.AddRecommendedSignals)
	populate(objectMap, "addResourceHealthSignal", d.AddResourceHealthSignal)
	populate(objectMap, "authenticationSetting", d.AuthenticationSetting)
	populate(objectMap, "discoverRelationships", d.DiscoverRelationships)
	populate(objectMap, "displayName", d.DisplayName)
	populate(objectMap, "entityName", d.EntityName)
	populate(objectMap, "error", d.Error)
	populate(objectMap, "provisioningState", d.ProvisioningState)
	populate(objectMap, "specification", d.Specification)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type DiscoveryRuleProperties.
func (d *DiscoveryRuleProperties) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", d, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "addRecommendedSignals":
			err = unpopulate(val, "AddRecommendedSignals", &d.AddRecommendedSignals)
			delete(rawMsg, key)
		case "addResourceHealthSignal":
			err = unpopulate(val, "AddResourceHealthSignal", &d.AddResourceHealthSignal)
			delete(rawMsg, key)
		case "authenticationSetting":
			err = unpopulate(val, "AuthenticationSetting", &d.AuthenticationSetting)
			delete(rawMsg, key)
		case "discoverRelationships":
			err = unpopulate(val, "DiscoverRelationships", &d.DiscoverRelationships)
			delete(rawMsg, key)
		case "displayName":
			err = unpopulate(val, "DisplayName", &d.DisplayName)
			delete(rawMsg, key)
		case "entityName":
			err = unpopulate(val, "EntityName", &d.EntityName)
			delete(rawMsg, key)
		case "error":
			err = unpopulate(val, "Error", &d.Error)
			delete(rawMsg, key)
		case "provisioningState":
			err = unpopulate(val, "ProvisioningState", &d.ProvisioningState)
			delete(rawMsg, key)
		case "specification":
			d.Specification, err = unmarshalDiscoveryRuleSpecificationClassification(val)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", d, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type DiscoveryRuleSpecification.
func (d DiscoveryRuleSpecification) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "kind", d.Kind)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type DiscoveryRuleSpecification.
func (d *DiscoveryRuleSpecification) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", d, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "kind":
			err = unpopulate(val, "Kind", &d.Kind)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", d, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type Entity.
func (e Entity) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "id", e.ID)
	populate(objectMap, "name", e.Name)
	populate(objectMap, "properties", e.Properties)
	populate(objectMap, "systemData", e.SystemData)
	populate(objectMap, "type", e.Type)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type Entity.
func (e *Entity) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", e, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "id":
			err = unpopulate(val, "ID", &e.ID)
			delete(rawMsg, key)
		case "name":
			err = unpopulate(val, "Name", &e.Name)
			delete(rawMsg, key)
		case "properties":
			err = unpopulate(val, "Properties", &e.Properties)
			delete(rawMsg, key)
		case "systemData":
			err = unpopulate(val, "SystemData", &e.SystemData)
			delete(rawMsg, key)
		case "type":
			err = unpopulate(val, "Type", &e.Type)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", e, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type EntityAlerts.
func (e EntityAlerts) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "degraded", e.Degraded)
	populate(objectMap, "unhealthy", e.Unhealthy)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type EntityAlerts.
func (e *EntityAlerts) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", e, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "degraded":
			err = unpopulate(val, "Degraded", &e.Degraded)
			delete(rawMsg, key)
		case "unhealthy":
			err = unpopulate(val, "Unhealthy", &e.Unhealthy)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", e, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type EntityCoordinates.
func (e EntityCoordinates) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "x", e.X)
	populate(objectMap, "y", e.Y)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type EntityCoordinates.
func (e *EntityCoordinates) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", e, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "x":
			err = unpopulate(val, "X", &e.X)
			delete(rawMsg, key)
		case "y":
			err = unpopulate(val, "Y", &e.Y)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", e, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type EntityHistoryRequest.
func (e EntityHistoryRequest) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populateTime[datetime.RFC3339](objectMap, "endAt", e.EndAt)
	populate(objectMap, "nextMarker", e.NextMarker)
	populateTime[datetime.RFC3339](objectMap, "startAt", e.StartAt)
	populate(objectMap, "top", e.Top)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type EntityHistoryRequest.
func (e *EntityHistoryRequest) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", e, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "endAt":
			err = unpopulateTime[datetime.RFC3339](val, "EndAt", &e.EndAt)
			delete(rawMsg, key)
		case "nextMarker":
			err = unpopulate(val, "NextMarker", &e.NextMarker)
			delete(rawMsg, key)
		case "startAt":
			err = unpopulateTime[datetime.RFC3339](val, "StartAt", &e.StartAt)
			delete(rawMsg, key)
		case "top":
			err = unpopulate(val, "Top", &e.Top)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", e, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type EntityHistoryResponse.
func (e EntityHistoryResponse) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "entityName", e.EntityName)
	populate(objectMap, "history", e.History)
	populate(objectMap, "nextMarker", e.NextMarker)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type EntityHistoryResponse.
func (e *EntityHistoryResponse) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", e, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "entityName":
			err = unpopulate(val, "EntityName", &e.EntityName)
			delete(rawMsg, key)
		case "history":
			err = unpopulate(val, "History", &e.History)
			delete(rawMsg, key)
		case "nextMarker":
			err = unpopulate(val, "NextMarker", &e.NextMarker)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", e, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type EntityListResult.
func (e EntityListResult) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "nextLink", e.NextLink)
	populate(objectMap, "value", e.Value)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type EntityListResult.
func (e *EntityListResult) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", e, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "nextLink":
			err = unpopulate(val, "NextLink", &e.NextLink)
			delete(rawMsg, key)
		case "value":
			err = unpopulate(val, "Value", &e.Value)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", e, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type EntityProperties.
func (e EntityProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "alerts", e.Alerts)
	populate(objectMap, "canvasPosition", e.CanvasPosition)
	populate(objectMap, "discoveredBy", e.DiscoveredBy)
	populate(objectMap, "displayName", e.DisplayName)
	populate(objectMap, "healthObjective", e.HealthObjective)
	populate(objectMap, "healthState", e.HealthState)
	populate(objectMap, "icon", e.Icon)
	populate(objectMap, "impact", e.Impact)
	populate(objectMap, "provisioningState", e.ProvisioningState)
	populate(objectMap, "signalGroups", e.SignalGroups)
	populate(objectMap, "tags", e.Tags)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type EntityProperties.
func (e *EntityProperties) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", e, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "alerts":
			err = unpopulate(val, "Alerts", &e.Alerts)
			delete(rawMsg, key)
		case "canvasPosition":
			err = unpopulate(val, "CanvasPosition", &e.CanvasPosition)
			delete(rawMsg, key)
		case "discoveredBy":
			err = unpopulate(val, "DiscoveredBy", &e.DiscoveredBy)
			delete(rawMsg, key)
		case "displayName":
			err = unpopulate(val, "DisplayName", &e.DisplayName)
			delete(rawMsg, key)
		case "healthObjective":
			err = unpopulate(val, "HealthObjective", &e.HealthObjective)
			delete(rawMsg, key)
		case "healthState":
			err = unpopulate(val, "HealthState", &e.HealthState)
			delete(rawMsg, key)
		case "icon":
			err = unpopulate(val, "Icon", &e.Icon)
			delete(rawMsg, key)
		case "impact":
			err = unpopulate(val, "Impact", &e.Impact)
			delete(rawMsg, key)
		case "provisioningState":
			err = unpopulate(val, "ProvisioningState", &e.ProvisioningState)
			delete(rawMsg, key)
		case "signalGroups":
			err = unpopulate(val, "SignalGroups", &e.SignalGroups)
			delete(rawMsg, key)
		case "tags":
			err = unpopulate(val, "Tags", &e.Tags)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", e, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type EvaluationRule.
func (e EvaluationRule) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "degradedRule", e.DegradedRule)
	populate(objectMap, "unhealthyRule", e.UnhealthyRule)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type EvaluationRule.
func (e *EvaluationRule) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", e, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "degradedRule":
			err = unpopulate(val, "DegradedRule", &e.DegradedRule)
			delete(rawMsg, key)
		case "unhealthyRule":
			err = unpopulate(val, "UnhealthyRule", &e.UnhealthyRule)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", e, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type ExternalSignal.
func (e ExternalSignal) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "evaluationRules", e.EvaluationRules)
	populate(objectMap, "name", e.Name)
	populate(objectMap, "signalDefinitionName", e.SignalDefinitionName)
	objectMap["signalKind"] = SignalKindExternalSignal
	populate(objectMap, "status", e.Status)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type ExternalSignal.
func (e *ExternalSignal) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", e, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "evaluationRules":
			err = unpopulate(val, "EvaluationRules", &e.EvaluationRules)
			delete(rawMsg, key)
		case "name":
			err = unpopulate(val, "Name", &e.Name)
			delete(rawMsg, key)
		case "signalDefinitionName":
			err = unpopulate(val, "SignalDefinitionName", &e.SignalDefinitionName)
			delete(rawMsg, key)
		case "signalKind":
			err = unpopulate(val, "SignalKind", &e.SignalKind)
			delete(rawMsg, key)
		case "status":
			err = unpopulate(val, "Status", &e.Status)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", e, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type ExternalSignalGroup.
func (e ExternalSignalGroup) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "signals", e.Signals)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type ExternalSignalGroup.
func (e *ExternalSignalGroup) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", e, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "signals":
			err = unpopulate(val, "Signals", &e.Signals)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", e, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type GetDataAnnotationsRequest.
func (g GetDataAnnotationsRequest) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populateTime[datetime.RFC3339](objectMap, "endAt", g.EndAt)
	populate(objectMap, "nextMarker", g.NextMarker)
	populateTime[datetime.RFC3339](objectMap, "startAt", g.StartAt)
	populate(objectMap, "top", g.Top)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type GetDataAnnotationsRequest.
func (g *GetDataAnnotationsRequest) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", g, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "endAt":
			err = unpopulateTime[datetime.RFC3339](val, "EndAt", &g.EndAt)
			delete(rawMsg, key)
		case "nextMarker":
			err = unpopulate(val, "NextMarker", &g.NextMarker)
			delete(rawMsg, key)
		case "startAt":
			err = unpopulateTime[datetime.RFC3339](val, "StartAt", &g.StartAt)
			delete(rawMsg, key)
		case "top":
			err = unpopulate(val, "Top", &g.Top)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", g, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type GetDataAnnotationsResponse.
func (g GetDataAnnotationsResponse) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "annotations", g.Annotations)
	populate(objectMap, "entityName", g.EntityName)
	populate(objectMap, "nextMarker", g.NextMarker)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type GetDataAnnotationsResponse.
func (g *GetDataAnnotationsResponse) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", g, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "annotations":
			err = unpopulate(val, "Annotations", &g.Annotations)
			delete(rawMsg, key)
		case "entityName":
			err = unpopulate(val, "EntityName", &g.EntityName)
			delete(rawMsg, key)
		case "nextMarker":
			err = unpopulate(val, "NextMarker", &g.NextMarker)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", g, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type GetSignalRecommendationsResponse.
func (g GetSignalRecommendationsResponse) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "recommendedConfigurations", g.RecommendedConfigurations)
	populate(objectMap, "recommendedSignals", g.RecommendedSignals)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type GetSignalRecommendationsResponse.
func (g *GetSignalRecommendationsResponse) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", g, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "recommendedConfigurations":
			err = unpopulate(val, "RecommendedConfigurations", &g.RecommendedConfigurations)
			delete(rawMsg, key)
		case "recommendedSignals":
			err = unpopulate(val, "RecommendedSignals", &g.RecommendedSignals)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", g, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type HealthModel.
func (h HealthModel) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "id", h.ID)
	populate(objectMap, "identity", h.Identity)
	populate(objectMap, "location", h.Location)
	populate(objectMap, "name", h.Name)
	populate(objectMap, "properties", h.Properties)
	populate(objectMap, "systemData", h.SystemData)
	populate(objectMap, "tags", h.Tags)
	populate(objectMap, "type", h.Type)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type HealthModel.
func (h *HealthModel) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", h, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "id":
			err = unpopulate(val, "ID", &h.ID)
			delete(rawMsg, key)
		case "identity":
			err = unpopulate(val, "Identity", &h.Identity)
			delete(rawMsg, key)
		case "location":
			err = unpopulate(val, "Location", &h.Location)
			delete(rawMsg, key)
		case "name":
			err = unpopulate(val, "Name", &h.Name)
			delete(rawMsg, key)
		case "properties":
			err = unpopulate(val, "Properties", &h.Properties)
			delete(rawMsg, key)
		case "systemData":
			err = unpopulate(val, "SystemData", &h.SystemData)
			delete(rawMsg, key)
		case "tags":
			err = unpopulate(val, "Tags", &h.Tags)
			delete(rawMsg, key)
		case "type":
			err = unpopulate(val, "Type", &h.Type)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", h, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type HealthModelListResult.
func (h HealthModelListResult) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "nextLink", h.NextLink)
	populate(objectMap, "value", h.Value)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type HealthModelListResult.
func (h *HealthModelListResult) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", h, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "nextLink":
			err = unpopulate(val, "NextLink", &h.NextLink)
			delete(rawMsg, key)
		case "value":
			err = unpopulate(val, "Value", &h.Value)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", h, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type HealthModelProperties.
func (h HealthModelProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "provisioningState", h.ProvisioningState)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type HealthModelProperties.
func (h *HealthModelProperties) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", h, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "provisioningState":
			err = unpopulate(val, "ProvisioningState", &h.ProvisioningState)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", h, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type HealthModelUpdate.
func (h HealthModelUpdate) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "identity", h.Identity)
	populate(objectMap, "tags", h.Tags)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type HealthModelUpdate.
func (h *HealthModelUpdate) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", h, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "identity":
			err = unpopulate(val, "Identity", &h.Identity)
			delete(rawMsg, key)
		case "tags":
			err = unpopulate(val, "Tags", &h.Tags)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", h, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type HealthReportEvaluationRule.
func (h HealthReportEvaluationRule) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "degradedRule", h.DegradedRule)
	populate(objectMap, "unhealthyRule", h.UnhealthyRule)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type HealthReportEvaluationRule.
func (h *HealthReportEvaluationRule) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", h, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "degradedRule":
			err = unpopulate(val, "DegradedRule", &h.DegradedRule)
			delete(rawMsg, key)
		case "unhealthyRule":
			err = unpopulate(val, "UnhealthyRule", &h.UnhealthyRule)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", h, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type HealthReportRequest.
func (h HealthReportRequest) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "additionalContext", h.AdditionalContext)
	populate(objectMap, "evaluationRules", h.EvaluationRules)
	populate(objectMap, "expiresInMinutes", h.ExpiresInMinutes)
	populate(objectMap, "healthState", h.HealthState)
	populate(objectMap, "signalName", h.SignalName)
	populate(objectMap, "value", h.Value)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type HealthReportRequest.
func (h *HealthReportRequest) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", h, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "additionalContext":
			err = unpopulate(val, "AdditionalContext", &h.AdditionalContext)
			delete(rawMsg, key)
		case "evaluationRules":
			err = unpopulate(val, "EvaluationRules", &h.EvaluationRules)
			delete(rawMsg, key)
		case "expiresInMinutes":
			err = unpopulate(val, "ExpiresInMinutes", &h.ExpiresInMinutes)
			delete(rawMsg, key)
		case "healthState":
			err = unpopulate(val, "HealthState", &h.HealthState)
			delete(rawMsg, key)
		case "signalName":
			err = unpopulate(val, "SignalName", &h.SignalName)
			delete(rawMsg, key)
		case "value":
			err = unpopulate(val, "Value", &h.Value)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", h, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type HealthStateTransition.
func (h HealthStateTransition) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "newState", h.NewState)
	populateTime[datetime.RFC3339](objectMap, "occurredAt", h.OccurredAt)
	populate(objectMap, "previousState", h.PreviousState)
	populate(objectMap, "reason", h.Reason)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type HealthStateTransition.
func (h *HealthStateTransition) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", h, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "newState":
			err = unpopulate(val, "NewState", &h.NewState)
			delete(rawMsg, key)
		case "occurredAt":
			err = unpopulateTime[datetime.RFC3339](val, "OccurredAt", &h.OccurredAt)
			delete(rawMsg, key)
		case "previousState":
			err = unpopulate(val, "PreviousState", &h.PreviousState)
			delete(rawMsg, key)
		case "reason":
			err = unpopulate(val, "Reason", &h.Reason)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", h, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type IconDefinition.
func (i IconDefinition) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "customData", i.CustomData)
	populate(objectMap, "iconName", i.IconName)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type IconDefinition.
func (i *IconDefinition) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", i, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "customData":
			err = unpopulate(val, "CustomData", &i.CustomData)
			delete(rawMsg, key)
		case "iconName":
			err = unpopulate(val, "IconName", &i.IconName)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", i, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type LogAnalyticsQuerySignalDefinitionProperties.
func (l LogAnalyticsQuerySignalDefinitionProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "dataUnit", l.DataUnit)
	populate(objectMap, "displayName", l.DisplayName)
	populate(objectMap, "evaluationRules", l.EvaluationRules)
	populate(objectMap, "provisioningState", l.ProvisioningState)
	populate(objectMap, "queryText", l.QueryText)
	populate(objectMap, "refreshInterval", l.RefreshInterval)
	objectMap["signalKind"] = SignalKindLogAnalyticsQuery
	populate(objectMap, "tags", l.Tags)
	populate(objectMap, "timeGrain", l.TimeGrain)
	populate(objectMap, "valueColumnName", l.ValueColumnName)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type LogAnalyticsQuerySignalDefinitionProperties.
func (l *LogAnalyticsQuerySignalDefinitionProperties) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", l, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "dataUnit":
			err = unpopulate(val, "DataUnit", &l.DataUnit)
			delete(rawMsg, key)
		case "displayName":
			err = unpopulate(val, "DisplayName", &l.DisplayName)
			delete(rawMsg, key)
		case "evaluationRules":
			err = unpopulate(val, "EvaluationRules", &l.EvaluationRules)
			delete(rawMsg, key)
		case "provisioningState":
			err = unpopulate(val, "ProvisioningState", &l.ProvisioningState)
			delete(rawMsg, key)
		case "queryText":
			err = unpopulate(val, "QueryText", &l.QueryText)
			delete(rawMsg, key)
		case "refreshInterval":
			err = unpopulate(val, "RefreshInterval", &l.RefreshInterval)
			delete(rawMsg, key)
		case "signalKind":
			err = unpopulate(val, "SignalKind", &l.SignalKind)
			delete(rawMsg, key)
		case "tags":
			err = unpopulate(val, "Tags", &l.Tags)
			delete(rawMsg, key)
		case "timeGrain":
			err = unpopulate(val, "TimeGrain", &l.TimeGrain)
			delete(rawMsg, key)
		case "valueColumnName":
			err = unpopulate(val, "ValueColumnName", &l.ValueColumnName)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", l, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type LogAnalyticsSignal.
func (l LogAnalyticsSignal) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "dataUnit", l.DataUnit)
	populate(objectMap, "displayName", l.DisplayName)
	populate(objectMap, "evaluationRules", l.EvaluationRules)
	populate(objectMap, "name", l.Name)
	populate(objectMap, "queryText", l.QueryText)
	populate(objectMap, "refreshInterval", l.RefreshInterval)
	populate(objectMap, "signalDefinitionName", l.SignalDefinitionName)
	objectMap["signalKind"] = SignalKindLogAnalyticsQuery
	populate(objectMap, "status", l.Status)
	populate(objectMap, "timeGrain", l.TimeGrain)
	populate(objectMap, "valueColumnName", l.ValueColumnName)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type LogAnalyticsSignal.
func (l *LogAnalyticsSignal) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", l, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "dataUnit":
			err = unpopulate(val, "DataUnit", &l.DataUnit)
			delete(rawMsg, key)
		case "displayName":
			err = unpopulate(val, "DisplayName", &l.DisplayName)
			delete(rawMsg, key)
		case "evaluationRules":
			err = unpopulate(val, "EvaluationRules", &l.EvaluationRules)
			delete(rawMsg, key)
		case "name":
			err = unpopulate(val, "Name", &l.Name)
			delete(rawMsg, key)
		case "queryText":
			err = unpopulate(val, "QueryText", &l.QueryText)
			delete(rawMsg, key)
		case "refreshInterval":
			err = unpopulate(val, "RefreshInterval", &l.RefreshInterval)
			delete(rawMsg, key)
		case "signalDefinitionName":
			err = unpopulate(val, "SignalDefinitionName", &l.SignalDefinitionName)
			delete(rawMsg, key)
		case "signalKind":
			err = unpopulate(val, "SignalKind", &l.SignalKind)
			delete(rawMsg, key)
		case "status":
			err = unpopulate(val, "Status", &l.Status)
			delete(rawMsg, key)
		case "timeGrain":
			err = unpopulate(val, "TimeGrain", &l.TimeGrain)
			delete(rawMsg, key)
		case "valueColumnName":
			err = unpopulate(val, "ValueColumnName", &l.ValueColumnName)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", l, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type LogAnalyticsSignals.
func (l LogAnalyticsSignals) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "authenticationSetting", l.AuthenticationSetting)
	populate(objectMap, "logAnalyticsWorkspaceResourceId", l.LogAnalyticsWorkspaceResourceID)
	populate(objectMap, "signals", l.Signals)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type LogAnalyticsSignals.
func (l *LogAnalyticsSignals) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", l, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "authenticationSetting":
			err = unpopulate(val, "AuthenticationSetting", &l.AuthenticationSetting)
			delete(rawMsg, key)
		case "logAnalyticsWorkspaceResourceId":
			err = unpopulate(val, "LogAnalyticsWorkspaceResourceID", &l.LogAnalyticsWorkspaceResourceID)
			delete(rawMsg, key)
		case "signals":
			err = unpopulate(val, "Signals", &l.Signals)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", l, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type ManagedIdentityAuthenticationSettingProperties.
func (m ManagedIdentityAuthenticationSettingProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	objectMap["authenticationKind"] = AuthenticationKindManagedIdentity
	populate(objectMap, "displayName", m.DisplayName)
	populate(objectMap, "managedIdentityName", m.ManagedIdentityName)
	populate(objectMap, "provisioningState", m.ProvisioningState)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedIdentityAuthenticationSettingProperties.
func (m *ManagedIdentityAuthenticationSettingProperties) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", m, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "authenticationKind":
			err = unpopulate(val, "AuthenticationKind", &m.AuthenticationKind)
			delete(rawMsg, key)
		case "displayName":
			err = unpopulate(val, "DisplayName", &m.DisplayName)
			delete(rawMsg, key)
		case "managedIdentityName":
			err = unpopulate(val, "ManagedIdentityName", &m.ManagedIdentityName)
			delete(rawMsg, key)
		case "provisioningState":
			err = unpopulate(val, "ProvisioningState", &m.ProvisioningState)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", m, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type ManagedServiceIdentity.
func (m ManagedServiceIdentity) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "principalId", m.PrincipalID)
	populate(objectMap, "tenantId", m.TenantID)
	populate(objectMap, "type", m.Type)
	populate(objectMap, "userAssignedIdentities", m.UserAssignedIdentities)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type ManagedServiceIdentity.
func (m *ManagedServiceIdentity) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", m, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "principalId":
			err = unpopulate(val, "PrincipalID", &m.PrincipalID)
			delete(rawMsg, key)
		case "tenantId":
			err = unpopulate(val, "TenantID", &m.TenantID)
			delete(rawMsg, key)
		case "type":
			err = unpopulate(val, "Type", &m.Type)
			delete(rawMsg, key)
		case "userAssignedIdentities":
			err = unpopulate(val, "UserAssignedIdentities", &m.UserAssignedIdentities)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", m, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type Operation.
func (o Operation) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "actionType", o.ActionType)
	populate(objectMap, "display", o.Display)
	populate(objectMap, "isDataAction", o.IsDataAction)
	populate(objectMap, "name", o.Name)
	populate(objectMap, "origin", o.Origin)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type Operation.
func (o *Operation) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", o, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "actionType":
			err = unpopulate(val, "ActionType", &o.ActionType)
			delete(rawMsg, key)
		case "display":
			err = unpopulate(val, "Display", &o.Display)
			delete(rawMsg, key)
		case "isDataAction":
			err = unpopulate(val, "IsDataAction", &o.IsDataAction)
			delete(rawMsg, key)
		case "name":
			err = unpopulate(val, "Name", &o.Name)
			delete(rawMsg, key)
		case "origin":
			err = unpopulate(val, "Origin", &o.Origin)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", o, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type OperationDisplay.
func (o OperationDisplay) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "description", o.Description)
	populate(objectMap, "operation", o.Operation)
	populate(objectMap, "provider", o.Provider)
	populate(objectMap, "resource", o.Resource)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay.
func (o *OperationDisplay) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", o, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "description":
			err = unpopulate(val, "Description", &o.Description)
			delete(rawMsg, key)
		case "operation":
			err = unpopulate(val, "Operation", &o.Operation)
			delete(rawMsg, key)
		case "provider":
			err = unpopulate(val, "Provider", &o.Provider)
			delete(rawMsg, key)
		case "resource":
			err = unpopulate(val, "Resource", &o.Resource)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", o, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type OperationListResult.
func (o OperationListResult) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "nextLink", o.NextLink)
	populate(objectMap, "value", o.Value)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult.
func (o *OperationListResult) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", o, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "nextLink":
			err = unpopulate(val, "NextLink", &o.NextLink)
			delete(rawMsg, key)
		case "value":
			err = unpopulate(val, "Value", &o.Value)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", o, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type PrometheusMetricsSignal.
func (p PrometheusMetricsSignal) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "dataUnit", p.DataUnit)
	populate(objectMap, "displayName", p.DisplayName)
	populate(objectMap, "evaluationRules", p.EvaluationRules)
	populate(objectMap, "name", p.Name)
	populate(objectMap, "queryText", p.QueryText)
	populate(objectMap, "refreshInterval", p.RefreshInterval)
	populate(objectMap, "signalDefinitionName", p.SignalDefinitionName)
	objectMap["signalKind"] = SignalKindPrometheusMetricsQuery
	populate(objectMap, "status", p.Status)
	populate(objectMap, "timeGrain", p.TimeGrain)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusMetricsSignal.
func (p *PrometheusMetricsSignal) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", p, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "dataUnit":
			err = unpopulate(val, "DataUnit", &p.DataUnit)
			delete(rawMsg, key)
		case "displayName":
			err = unpopulate(val, "DisplayName", &p.DisplayName)
			delete(rawMsg, key)
		case "evaluationRules":
			err = unpopulate(val, "EvaluationRules", &p.EvaluationRules)
			delete(rawMsg, key)
		case "name":
			err = unpopulate(val, "Name", &p.Name)
			delete(rawMsg, key)
		case "queryText":
			err = unpopulate(val, "QueryText", &p.QueryText)
			delete(rawMsg, key)
		case "refreshInterval":
			err = unpopulate(val, "RefreshInterval", &p.RefreshInterval)
			delete(rawMsg, key)
		case "signalDefinitionName":
			err = unpopulate(val, "SignalDefinitionName", &p.SignalDefinitionName)
			delete(rawMsg, key)
		case "signalKind":
			err = unpopulate(val, "SignalKind", &p.SignalKind)
			delete(rawMsg, key)
		case "status":
			err = unpopulate(val, "Status", &p.Status)
			delete(rawMsg, key)
		case "timeGrain":
			err = unpopulate(val, "TimeGrain", &p.TimeGrain)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", p, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type PrometheusMetricsSignalDefinitionProperties.
func (p PrometheusMetricsSignalDefinitionProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "dataUnit", p.DataUnit)
	populate(objectMap, "displayName", p.DisplayName)
	populate(objectMap, "evaluationRules", p.EvaluationRules)
	populate(objectMap, "provisioningState", p.ProvisioningState)
	populate(objectMap, "queryText", p.QueryText)
	populate(objectMap, "refreshInterval", p.RefreshInterval)
	objectMap["signalKind"] = SignalKindPrometheusMetricsQuery
	populate(objectMap, "tags", p.Tags)
	populate(objectMap, "timeGrain", p.TimeGrain)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type PrometheusMetricsSignalDefinitionProperties.
func (p *PrometheusMetricsSignalDefinitionProperties) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", p, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "dataUnit":
			err = unpopulate(val, "DataUnit", &p.DataUnit)
			delete(rawMsg, key)
		case "displayName":
			err = unpopulate(val, "DisplayName", &p.DisplayName)
			delete(rawMsg, key)
		case "evaluationRules":
			err = unpopulate(val, "EvaluationRules", &p.EvaluationRules)
			delete(rawMsg, key)
		case "provisioningState":
			err = unpopulate(val, "ProvisioningState", &p.ProvisioningState)
			delete(rawMsg, key)
		case "queryText":
			err = unpopulate(val, "QueryText", &p.QueryText)
			delete(rawMsg, key)
		case "refreshInterval":
			err = unpopulate(val, "RefreshInterval", &p.RefreshInterval)
			delete(rawMsg, key)
		case "signalKind":
			err = unpopulate(val, "SignalKind", &p.SignalKind)
			delete(rawMsg, key)
		case "tags":
			err = unpopulate(val, "Tags", &p.Tags)
			delete(rawMsg, key)
		case "timeGrain":
			err = unpopulate(val, "TimeGrain", &p.TimeGrain)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", p, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type Relationship.
func (r Relationship) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "id", r.ID)
	populate(objectMap, "name", r.Name)
	populate(objectMap, "properties", r.Properties)
	populate(objectMap, "systemData", r.SystemData)
	populate(objectMap, "type", r.Type)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type Relationship.
func (r *Relationship) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", r, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "id":
			err = unpopulate(val, "ID", &r.ID)
			delete(rawMsg, key)
		case "name":
			err = unpopulate(val, "Name", &r.Name)
			delete(rawMsg, key)
		case "properties":
			err = unpopulate(val, "Properties", &r.Properties)
			delete(rawMsg, key)
		case "systemData":
			err = unpopulate(val, "SystemData", &r.SystemData)
			delete(rawMsg, key)
		case "type":
			err = unpopulate(val, "Type", &r.Type)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", r, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type RelationshipListResult.
func (r RelationshipListResult) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "nextLink", r.NextLink)
	populate(objectMap, "value", r.Value)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type RelationshipListResult.
func (r *RelationshipListResult) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", r, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "nextLink":
			err = unpopulate(val, "NextLink", &r.NextLink)
			delete(rawMsg, key)
		case "value":
			err = unpopulate(val, "Value", &r.Value)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", r, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type RelationshipProperties.
func (r RelationshipProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "childEntityName", r.ChildEntityName)
	populate(objectMap, "discoveredBy", r.DiscoveredBy)
	populate(objectMap, "displayName", r.DisplayName)
	populate(objectMap, "parentEntityName", r.ParentEntityName)
	populate(objectMap, "provisioningState", r.ProvisioningState)
	populate(objectMap, "tags", r.Tags)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type RelationshipProperties.
func (r *RelationshipProperties) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", r, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "childEntityName":
			err = unpopulate(val, "ChildEntityName", &r.ChildEntityName)
			delete(rawMsg, key)
		case "discoveredBy":
			err = unpopulate(val, "DiscoveredBy", &r.DiscoveredBy)
			delete(rawMsg, key)
		case "displayName":
			err = unpopulate(val, "DisplayName", &r.DisplayName)
			delete(rawMsg, key)
		case "parentEntityName":
			err = unpopulate(val, "ParentEntityName", &r.ParentEntityName)
			delete(rawMsg, key)
		case "provisioningState":
			err = unpopulate(val, "ProvisioningState", &r.ProvisioningState)
			delete(rawMsg, key)
		case "tags":
			err = unpopulate(val, "Tags", &r.Tags)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", r, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type ResourceGraphQuerySpecification.
func (r ResourceGraphQuerySpecification) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	objectMap["kind"] = DiscoveryRuleKindResourceGraphQuery
	populate(objectMap, "resourceGraphQuery", r.ResourceGraphQuery)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceGraphQuerySpecification.
func (r *ResourceGraphQuerySpecification) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", r, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "kind":
			err = unpopulate(val, "Kind", &r.Kind)
			delete(rawMsg, key)
		case "resourceGraphQuery":
			err = unpopulate(val, "ResourceGraphQuery", &r.ResourceGraphQuery)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", r, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type ResourceMetricSignalDefinitionProperties.
func (r ResourceMetricSignalDefinitionProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "aggregationType", r.AggregationType)
	populate(objectMap, "dataUnit", r.DataUnit)
	populate(objectMap, "dimensionFilter", r.DimensionFilter)
	populate(objectMap, "displayName", r.DisplayName)
	populate(objectMap, "evaluationRules", r.EvaluationRules)
	populate(objectMap, "metricName", r.MetricName)
	populate(objectMap, "metricNamespace", r.MetricNamespace)
	populate(objectMap, "provisioningState", r.ProvisioningState)
	populate(objectMap, "refreshInterval", r.RefreshInterval)
	objectMap["signalKind"] = SignalKindAzureResourceMetric
	populate(objectMap, "tags", r.Tags)
	populate(objectMap, "timeGrain", r.TimeGrain)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type ResourceMetricSignalDefinitionProperties.
func (r *ResourceMetricSignalDefinitionProperties) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", r, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "aggregationType":
			err = unpopulate(val, "AggregationType", &r.AggregationType)
			delete(rawMsg, key)
		case "dataUnit":
			err = unpopulate(val, "DataUnit", &r.DataUnit)
			delete(rawMsg, key)
		case "dimensionFilter":
			err = unpopulate(val, "DimensionFilter", &r.DimensionFilter)
			delete(rawMsg, key)
		case "displayName":
			err = unpopulate(val, "DisplayName", &r.DisplayName)
			delete(rawMsg, key)
		case "evaluationRules":
			err = unpopulate(val, "EvaluationRules", &r.EvaluationRules)
			delete(rawMsg, key)
		case "metricName":
			err = unpopulate(val, "MetricName", &r.MetricName)
			delete(rawMsg, key)
		case "metricNamespace":
			err = unpopulate(val, "MetricNamespace", &r.MetricNamespace)
			delete(rawMsg, key)
		case "provisioningState":
			err = unpopulate(val, "ProvisioningState", &r.ProvisioningState)
			delete(rawMsg, key)
		case "refreshInterval":
			err = unpopulate(val, "RefreshInterval", &r.RefreshInterval)
			delete(rawMsg, key)
		case "signalKind":
			err = unpopulate(val, "SignalKind", &r.SignalKind)
			delete(rawMsg, key)
		case "tags":
			err = unpopulate(val, "Tags", &r.Tags)
			delete(rawMsg, key)
		case "timeGrain":
			err = unpopulate(val, "TimeGrain", &r.TimeGrain)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", r, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type SignalConfiguration.
func (s SignalConfiguration) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "aggregationType", s.AggregationType)
	populate(objectMap, "dimensionFilter", s.DimensionFilter)
	populate(objectMap, "evaluationRules", s.EvaluationRules)
	populate(objectMap, "metricName", s.MetricName)
	populate(objectMap, "metricNamespace", s.MetricNamespace)
	populate(objectMap, "signalId", s.SignalID)
	populate(objectMap, "timeGrain", s.TimeGrain)
	populate(objectMap, "unit", s.Unit)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type SignalConfiguration.
func (s *SignalConfiguration) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "aggregationType":
			err = unpopulate(val, "AggregationType", &s.AggregationType)
			delete(rawMsg, key)
		case "dimensionFilter":
			err = unpopulate(val, "DimensionFilter", &s.DimensionFilter)
			delete(rawMsg, key)
		case "evaluationRules":
			err = unpopulate(val, "EvaluationRules", &s.EvaluationRules)
			delete(rawMsg, key)
		case "metricName":
			err = unpopulate(val, "MetricName", &s.MetricName)
			delete(rawMsg, key)
		case "metricNamespace":
			err = unpopulate(val, "MetricNamespace", &s.MetricNamespace)
			delete(rawMsg, key)
		case "signalId":
			err = unpopulate(val, "SignalID", &s.SignalID)
			delete(rawMsg, key)
		case "timeGrain":
			err = unpopulate(val, "TimeGrain", &s.TimeGrain)
			delete(rawMsg, key)
		case "unit":
			err = unpopulate(val, "Unit", &s.Unit)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type SignalDefinition.
func (s SignalDefinition) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "id", s.ID)
	populate(objectMap, "name", s.Name)
	populate(objectMap, "properties", s.Properties)
	populate(objectMap, "systemData", s.SystemData)
	populate(objectMap, "type", s.Type)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type SignalDefinition.
func (s *SignalDefinition) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "id":
			err = unpopulate(val, "ID", &s.ID)
			delete(rawMsg, key)
		case "name":
			err = unpopulate(val, "Name", &s.Name)
			delete(rawMsg, key)
		case "properties":
			s.Properties, err = unmarshalSignalDefinitionPropertiesClassification(val)
			delete(rawMsg, key)
		case "systemData":
			err = unpopulate(val, "SystemData", &s.SystemData)
			delete(rawMsg, key)
		case "type":
			err = unpopulate(val, "Type", &s.Type)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type SignalDefinitionListResult.
func (s SignalDefinitionListResult) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "nextLink", s.NextLink)
	populate(objectMap, "value", s.Value)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type SignalDefinitionListResult.
func (s *SignalDefinitionListResult) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "nextLink":
			err = unpopulate(val, "NextLink", &s.NextLink)
			delete(rawMsg, key)
		case "value":
			err = unpopulate(val, "Value", &s.Value)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type SignalDefinitionProperties.
func (s SignalDefinitionProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "dataUnit", s.DataUnit)
	populate(objectMap, "displayName", s.DisplayName)
	populate(objectMap, "evaluationRules", s.EvaluationRules)
	populate(objectMap, "provisioningState", s.ProvisioningState)
	populate(objectMap, "refreshInterval", s.RefreshInterval)
	populate(objectMap, "signalKind", s.SignalKind)
	populate(objectMap, "tags", s.Tags)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type SignalDefinitionProperties.
func (s *SignalDefinitionProperties) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "dataUnit":
			err = unpopulate(val, "DataUnit", &s.DataUnit)
			delete(rawMsg, key)
		case "displayName":
			err = unpopulate(val, "DisplayName", &s.DisplayName)
			delete(rawMsg, key)
		case "evaluationRules":
			err = unpopulate(val, "EvaluationRules", &s.EvaluationRules)
			delete(rawMsg, key)
		case "provisioningState":
			err = unpopulate(val, "ProvisioningState", &s.ProvisioningState)
			delete(rawMsg, key)
		case "refreshInterval":
			err = unpopulate(val, "RefreshInterval", &s.RefreshInterval)
			delete(rawMsg, key)
		case "signalKind":
			err = unpopulate(val, "SignalKind", &s.SignalKind)
			delete(rawMsg, key)
		case "tags":
			err = unpopulate(val, "Tags", &s.Tags)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type SignalGroups.
func (s SignalGroups) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "azureLogAnalytics", s.AzureLogAnalytics)
	populate(objectMap, "azureMonitorWorkspace", s.AzureMonitorWorkspace)
	populate(objectMap, "azureResource", s.AzureResource)
	populate(objectMap, "dependencies", s.Dependencies)
	populate(objectMap, "external", s.External)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type SignalGroups.
func (s *SignalGroups) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "azureLogAnalytics":
			err = unpopulate(val, "AzureLogAnalytics", &s.AzureLogAnalytics)
			delete(rawMsg, key)
		case "azureMonitorWorkspace":
			err = unpopulate(val, "AzureMonitorWorkspace", &s.AzureMonitorWorkspace)
			delete(rawMsg, key)
		case "azureResource":
			err = unpopulate(val, "AzureResource", &s.AzureResource)
			delete(rawMsg, key)
		case "dependencies":
			err = unpopulate(val, "Dependencies", &s.Dependencies)
			delete(rawMsg, key)
		case "external":
			err = unpopulate(val, "External", &s.External)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type SignalHistoryDataPoint.
func (s SignalHistoryDataPoint) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "additionalContext", s.AdditionalContext)
	populate(objectMap, "healthState", s.HealthState)
	populateTime[datetime.RFC3339](objectMap, "occurredAt", s.OccurredAt)
	populate(objectMap, "value", s.Value)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type SignalHistoryDataPoint.
func (s *SignalHistoryDataPoint) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "additionalContext":
			err = unpopulate(val, "AdditionalContext", &s.AdditionalContext)
			delete(rawMsg, key)
		case "healthState":
			err = unpopulate(val, "HealthState", &s.HealthState)
			delete(rawMsg, key)
		case "occurredAt":
			err = unpopulateTime[datetime.RFC3339](val, "OccurredAt", &s.OccurredAt)
			delete(rawMsg, key)
		case "value":
			err = unpopulate(val, "Value", &s.Value)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type SignalHistoryRequest.
func (s SignalHistoryRequest) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populateTime[datetime.RFC3339](objectMap, "endAt", s.EndAt)
	populate(objectMap, "nextMarker", s.NextMarker)
	populate(objectMap, "signalName", s.SignalName)
	populateTime[datetime.RFC3339](objectMap, "startAt", s.StartAt)
	populate(objectMap, "top", s.Top)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type SignalHistoryRequest.
func (s *SignalHistoryRequest) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "endAt":
			err = unpopulateTime[datetime.RFC3339](val, "EndAt", &s.EndAt)
			delete(rawMsg, key)
		case "nextMarker":
			err = unpopulate(val, "NextMarker", &s.NextMarker)
			delete(rawMsg, key)
		case "signalName":
			err = unpopulate(val, "SignalName", &s.SignalName)
			delete(rawMsg, key)
		case "startAt":
			err = unpopulateTime[datetime.RFC3339](val, "StartAt", &s.StartAt)
			delete(rawMsg, key)
		case "top":
			err = unpopulate(val, "Top", &s.Top)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type SignalHistoryResponse.
func (s SignalHistoryResponse) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "entityName", s.EntityName)
	populate(objectMap, "history", s.History)
	populate(objectMap, "nextMarker", s.NextMarker)
	populate(objectMap, "signalName", s.SignalName)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type SignalHistoryResponse.
func (s *SignalHistoryResponse) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "entityName":
			err = unpopulate(val, "EntityName", &s.EntityName)
			delete(rawMsg, key)
		case "history":
			err = unpopulate(val, "History", &s.History)
			delete(rawMsg, key)
		case "nextMarker":
			err = unpopulate(val, "NextMarker", &s.NextMarker)
			delete(rawMsg, key)
		case "signalName":
			err = unpopulate(val, "SignalName", &s.SignalName)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type SignalInstanceProperties.
func (s SignalInstanceProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "name", s.Name)
	populate(objectMap, "signalDefinitionName", s.SignalDefinitionName)
	populate(objectMap, "signalKind", s.SignalKind)
	populate(objectMap, "status", s.Status)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type SignalInstanceProperties.
func (s *SignalInstanceProperties) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "name":
			err = unpopulate(val, "Name", &s.Name)
			delete(rawMsg, key)
		case "signalDefinitionName":
			err = unpopulate(val, "SignalDefinitionName", &s.SignalDefinitionName)
			delete(rawMsg, key)
		case "signalKind":
			err = unpopulate(val, "SignalKind", &s.SignalKind)
			delete(rawMsg, key)
		case "status":
			err = unpopulate(val, "Status", &s.Status)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type SignalStatus.
func (s SignalStatus) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "additionalContext", s.AdditionalContext)
	populate(objectMap, "error", s.Error)
	populate(objectMap, "healthState", s.HealthState)
	populateTime[datetime.RFC3339](objectMap, "reportedAt", s.ReportedAt)
	populate(objectMap, "value", s.Value)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type SignalStatus.
func (s *SignalStatus) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "additionalContext":
			err = unpopulate(val, "AdditionalContext", &s.AdditionalContext)
			delete(rawMsg, key)
		case "error":
			err = unpopulate(val, "Error", &s.Error)
			delete(rawMsg, key)
		case "healthState":
			err = unpopulate(val, "HealthState", &s.HealthState)
			delete(rawMsg, key)
		case "reportedAt":
			err = unpopulateTime[datetime.RFC3339](val, "ReportedAt", &s.ReportedAt)
			delete(rawMsg, key)
		case "value":
			err = unpopulate(val, "Value", &s.Value)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type SystemData.
func (s SystemData) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populateTime[datetime.RFC3339](objectMap, "createdAt", s.CreatedAt)
	populate(objectMap, "createdBy", s.CreatedBy)
	populate(objectMap, "createdByType", s.CreatedByType)
	populateTime[datetime.RFC3339](objectMap, "lastModifiedAt", s.LastModifiedAt)
	populate(objectMap, "lastModifiedBy", s.LastModifiedBy)
	populate(objectMap, "lastModifiedByType", s.LastModifiedByType)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData.
func (s *SystemData) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "createdAt":
			err = unpopulateTime[datetime.RFC3339](val, "CreatedAt", &s.CreatedAt)
			delete(rawMsg, key)
		case "createdBy":
			err = unpopulate(val, "CreatedBy", &s.CreatedBy)
			delete(rawMsg, key)
		case "createdByType":
			err = unpopulate(val, "CreatedByType", &s.CreatedByType)
			delete(rawMsg, key)
		case "lastModifiedAt":
			err = unpopulateTime[datetime.RFC3339](val, "LastModifiedAt", &s.LastModifiedAt)
			delete(rawMsg, key)
		case "lastModifiedBy":
			err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy)
			delete(rawMsg, key)
		case "lastModifiedByType":
			err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", s, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type ThresholdRuleV2.
func (t ThresholdRuleV2) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "lookBackWindow", t.LookBackWindow)
	populate(objectMap, "operator", t.Operator)
	populate(objectMap, "sensitivity", t.Sensitivity)
	populate(objectMap, "threshold", t.Threshold)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type ThresholdRuleV2.
func (t *ThresholdRuleV2) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", t, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "lookBackWindow":
			err = unpopulate(val, "LookBackWindow", &t.LookBackWindow)
			delete(rawMsg, key)
		case "operator":
			err = unpopulate(val, "Operator", &t.Operator)
			delete(rawMsg, key)
		case "sensitivity":
			err = unpopulate(val, "Sensitivity", &t.Sensitivity)
			delete(rawMsg, key)
		case "threshold":
			err = unpopulate(val, "Threshold", &t.Threshold)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", t, err.Error())
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type UserAssignedIdentity.
func (u UserAssignedIdentity) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "clientId", u.ClientID)
	populate(objectMap, "principalId", u.PrincipalID)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type UserAssignedIdentity.
func (u *UserAssignedIdentity) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %s", u, err.Error())
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "clientId":
			err = unpopulate(val, "ClientID", &u.ClientID)
			delete(rawMsg, key)
		case "principalId":
			err = unpopulate(val, "PrincipalID", &u.PrincipalID)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %s", u, err.Error())
		}
	}
	return nil
}

func populate(m map[string]any, k string, v any) {
	if v == nil {
		return
	} else if azcore.IsNullValue(v) {
		m[k] = nil
	} else if !reflect.ValueOf(v).IsNil() {
		m[k] = v
	}
}

func populateTime[T dateTimeConstraints](m map[string]any, k string, t *time.Time) {
	if t == nil {
		return
	} else if azcore.IsNullValue(t) {
		m[k] = nil
	} else if !reflect.ValueOf(t).IsNil() {
		newTime := T(*t)
		m[k] = (*T)(&newTime)
	}
}

func unpopulate(data json.RawMessage, fn string, v any) error {
	if data == nil || string(data) == "null" {
		return nil
	}
	if err := json.Unmarshal(data, v); err != nil {
		return fmt.Errorf("struct field %s: %v", fn, err)
	}
	return nil
}

func unpopulateTime[T dateTimeConstraints](data json.RawMessage, fn string, t **time.Time) error {
	if data == nil || string(data) == "null" {
		return nil
	}
	var aux T
	if err := json.Unmarshal(data, &aux); err != nil {
		return fmt.Errorf("struct field %s: %v", fn, err)
	}
	newTime := time.Time(aux)
	*t = &newTime
	return nil
}

type dateTimeConstraints interface {
	datetime.PlainDate | datetime.PlainTime | datetime.RFC3339 | datetime.RFC7231 | datetime.Unix
}
