// 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 armdisconnectedoperations

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 Artifact.
func (a Artifact) 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 Artifact.
func (a *Artifact) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %v", a, err)
	}
	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":
			err = unpopulate(val, "Properties", &a.Properties)
			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: %v", a, err)
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type ArtifactDownloadResult.
func (a ArtifactDownloadResult) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "artifactOrder", a.ArtifactOrder)
	populate(objectMap, "description", a.Description)
	populate(objectMap, "downloadLink", a.DownloadLink)
	populateTime[datetime.RFC3339](objectMap, "linkExpiry", a.LinkExpiry)
	populate(objectMap, "provisioningState", a.ProvisioningState)
	populate(objectMap, "size", a.Size)
	populate(objectMap, "title", a.Title)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type ArtifactDownloadResult.
func (a *ArtifactDownloadResult) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %v", a, err)
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "artifactOrder":
			err = unpopulate(val, "ArtifactOrder", &a.ArtifactOrder)
			delete(rawMsg, key)
		case "description":
			err = unpopulate(val, "Description", &a.Description)
			delete(rawMsg, key)
		case "downloadLink":
			err = unpopulate(val, "DownloadLink", &a.DownloadLink)
			delete(rawMsg, key)
		case "linkExpiry":
			err = unpopulateTime[datetime.RFC3339](val, "LinkExpiry", &a.LinkExpiry)
			delete(rawMsg, key)
		case "provisioningState":
			err = unpopulate(val, "ProvisioningState", &a.ProvisioningState)
			delete(rawMsg, key)
		case "size":
			err = unpopulate(val, "Size", &a.Size)
			delete(rawMsg, key)
		case "title":
			err = unpopulate(val, "Title", &a.Title)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %v", a, err)
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type ArtifactListResult.
func (a ArtifactListResult) 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 ArtifactListResult.
func (a *ArtifactListResult) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %v", a, err)
	}
	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: %v", a, err)
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type ArtifactProperties.
func (a ArtifactProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "artifactOrder", a.ArtifactOrder)
	populate(objectMap, "description", a.Description)
	populate(objectMap, "provisioningState", a.ProvisioningState)
	populate(objectMap, "size", a.Size)
	populate(objectMap, "title", a.Title)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type ArtifactProperties.
func (a *ArtifactProperties) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %v", a, err)
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "artifactOrder":
			err = unpopulate(val, "ArtifactOrder", &a.ArtifactOrder)
			delete(rawMsg, key)
		case "description":
			err = unpopulate(val, "Description", &a.Description)
			delete(rawMsg, key)
		case "provisioningState":
			err = unpopulate(val, "ProvisioningState", &a.ProvisioningState)
			delete(rawMsg, key)
		case "size":
			err = unpopulate(val, "Size", &a.Size)
			delete(rawMsg, key)
		case "title":
			err = unpopulate(val, "Title", &a.Title)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %v", a, err)
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type BenefitPlans.
func (b BenefitPlans) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "azureHybridWindowsServerBenefit", b.AzureHybridWindowsServerBenefit)
	populate(objectMap, "windowsServerVmCount", b.WindowsServerVMCount)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type BenefitPlans.
func (b *BenefitPlans) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %v", b, err)
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "azureHybridWindowsServerBenefit":
			err = unpopulate(val, "AzureHybridWindowsServerBenefit", &b.AzureHybridWindowsServerBenefit)
			delete(rawMsg, key)
		case "windowsServerVmCount":
			err = unpopulate(val, "WindowsServerVMCount", &b.WindowsServerVMCount)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %v", b, err)
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type BillingConfiguration.
func (b BillingConfiguration) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "autoRenew", b.AutoRenew)
	populate(objectMap, "billingStatus", b.BillingStatus)
	populate(objectMap, "current", b.Current)
	populate(objectMap, "upcoming", b.Upcoming)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type BillingConfiguration.
func (b *BillingConfiguration) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %v", b, err)
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "autoRenew":
			err = unpopulate(val, "AutoRenew", &b.AutoRenew)
			delete(rawMsg, key)
		case "billingStatus":
			err = unpopulate(val, "BillingStatus", &b.BillingStatus)
			delete(rawMsg, key)
		case "current":
			err = unpopulate(val, "Current", &b.Current)
			delete(rawMsg, key)
		case "upcoming":
			err = unpopulate(val, "Upcoming", &b.Upcoming)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %v", b, err)
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type BillingPeriod.
func (b BillingPeriod) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "cores", b.Cores)
	populateTime[datetime.PlainDate](objectMap, "endDate", b.EndDate)
	populate(objectMap, "pricingModel", b.PricingModel)
	populateTime[datetime.PlainDate](objectMap, "startDate", b.StartDate)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type BillingPeriod.
func (b *BillingPeriod) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %v", b, err)
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "cores":
			err = unpopulate(val, "Cores", &b.Cores)
			delete(rawMsg, key)
		case "endDate":
			err = unpopulateTime[datetime.PlainDate](val, "EndDate", &b.EndDate)
			delete(rawMsg, key)
		case "pricingModel":
			err = unpopulate(val, "PricingModel", &b.PricingModel)
			delete(rawMsg, key)
		case "startDate":
			err = unpopulateTime[datetime.PlainDate](val, "StartDate", &b.StartDate)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %v", b, err)
		}
	}
	return nil
}

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

// UnmarshalJSON implements the json.Unmarshaller interface for type DisconnectedOperation.
func (d *DisconnectedOperation) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %v", d, err)
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "id":
			err = unpopulate(val, "ID", &d.ID)
			delete(rawMsg, key)
		case "location":
			err = unpopulate(val, "Location", &d.Location)
			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 "tags":
			err = unpopulate(val, "Tags", &d.Tags)
			delete(rawMsg, key)
		case "type":
			err = unpopulate(val, "Type", &d.Type)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %v", d, err)
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type DisconnectedOperationDeploymentManifest.
func (d DisconnectedOperationDeploymentManifest) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "benefitPlans", d.BenefitPlans)
	populate(objectMap, "billingConfiguration", d.BillingConfiguration)
	populate(objectMap, "billingModel", d.BillingModel)
	populate(objectMap, "cloud", d.Cloud)
	populate(objectMap, "connectionIntent", d.ConnectionIntent)
	populate(objectMap, "location", d.Location)
	populate(objectMap, "resourceId", d.ResourceID)
	populate(objectMap, "resourceName", d.ResourceName)
	populate(objectMap, "stampId", d.StampID)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type DisconnectedOperationDeploymentManifest.
func (d *DisconnectedOperationDeploymentManifest) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %v", d, err)
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "benefitPlans":
			err = unpopulate(val, "BenefitPlans", &d.BenefitPlans)
			delete(rawMsg, key)
		case "billingConfiguration":
			err = unpopulate(val, "BillingConfiguration", &d.BillingConfiguration)
			delete(rawMsg, key)
		case "billingModel":
			err = unpopulate(val, "BillingModel", &d.BillingModel)
			delete(rawMsg, key)
		case "cloud":
			err = unpopulate(val, "Cloud", &d.Cloud)
			delete(rawMsg, key)
		case "connectionIntent":
			err = unpopulate(val, "ConnectionIntent", &d.ConnectionIntent)
			delete(rawMsg, key)
		case "location":
			err = unpopulate(val, "Location", &d.Location)
			delete(rawMsg, key)
		case "resourceId":
			err = unpopulate(val, "ResourceID", &d.ResourceID)
			delete(rawMsg, key)
		case "resourceName":
			err = unpopulate(val, "ResourceName", &d.ResourceName)
			delete(rawMsg, key)
		case "stampId":
			err = unpopulate(val, "StampID", &d.StampID)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %v", d, err)
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type DisconnectedOperationListResult.
func (d DisconnectedOperationListResult) 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 DisconnectedOperationListResult.
func (d *DisconnectedOperationListResult) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %v", d, err)
	}
	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: %v", d, err)
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type DisconnectedOperationProperties.
func (d DisconnectedOperationProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "benefitPlans", d.BenefitPlans)
	populate(objectMap, "billingConfiguration", d.BillingConfiguration)
	populate(objectMap, "billingModel", d.BillingModel)
	populate(objectMap, "connectionIntent", d.ConnectionIntent)
	populate(objectMap, "connectionStatus", d.ConnectionStatus)
	populate(objectMap, "deviceVersion", d.DeviceVersion)
	populate(objectMap, "provisioningState", d.ProvisioningState)
	populate(objectMap, "registrationStatus", d.RegistrationStatus)
	populate(objectMap, "stampId", d.StampID)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type DisconnectedOperationProperties.
func (d *DisconnectedOperationProperties) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %v", d, err)
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "benefitPlans":
			err = unpopulate(val, "BenefitPlans", &d.BenefitPlans)
			delete(rawMsg, key)
		case "billingConfiguration":
			err = unpopulate(val, "BillingConfiguration", &d.BillingConfiguration)
			delete(rawMsg, key)
		case "billingModel":
			err = unpopulate(val, "BillingModel", &d.BillingModel)
			delete(rawMsg, key)
		case "connectionIntent":
			err = unpopulate(val, "ConnectionIntent", &d.ConnectionIntent)
			delete(rawMsg, key)
		case "connectionStatus":
			err = unpopulate(val, "ConnectionStatus", &d.ConnectionStatus)
			delete(rawMsg, key)
		case "deviceVersion":
			err = unpopulate(val, "DeviceVersion", &d.DeviceVersion)
			delete(rawMsg, key)
		case "provisioningState":
			err = unpopulate(val, "ProvisioningState", &d.ProvisioningState)
			delete(rawMsg, key)
		case "registrationStatus":
			err = unpopulate(val, "RegistrationStatus", &d.RegistrationStatus)
			delete(rawMsg, key)
		case "stampId":
			err = unpopulate(val, "StampID", &d.StampID)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %v", d, err)
		}
	}
	return nil
}

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

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

// MarshalJSON implements the json.Marshaller interface for type DisconnectedOperationUpdateProperties.
func (d DisconnectedOperationUpdateProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "benefitPlans", d.BenefitPlans)
	populate(objectMap, "billingConfiguration", d.BillingConfiguration)
	populate(objectMap, "connectionIntent", d.ConnectionIntent)
	populate(objectMap, "deviceVersion", d.DeviceVersion)
	populate(objectMap, "registrationStatus", d.RegistrationStatus)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type DisconnectedOperationUpdateProperties.
func (d *DisconnectedOperationUpdateProperties) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %v", d, err)
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "benefitPlans":
			err = unpopulate(val, "BenefitPlans", &d.BenefitPlans)
			delete(rawMsg, key)
		case "billingConfiguration":
			err = unpopulate(val, "BillingConfiguration", &d.BillingConfiguration)
			delete(rawMsg, key)
		case "connectionIntent":
			err = unpopulate(val, "ConnectionIntent", &d.ConnectionIntent)
			delete(rawMsg, key)
		case "deviceVersion":
			err = unpopulate(val, "DeviceVersion", &d.DeviceVersion)
			delete(rawMsg, key)
		case "registrationStatus":
			err = unpopulate(val, "RegistrationStatus", &d.RegistrationStatus)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %v", d, err)
		}
	}
	return nil
}

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

// UnmarshalJSON implements the json.Unmarshaller interface for type HardwareSetting.
func (h *HardwareSetting) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %v", h, err)
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "id":
			err = unpopulate(val, "ID", &h.ID)
			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 "type":
			err = unpopulate(val, "Type", &h.Type)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %v", h, err)
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type HardwareSettingListResult.
func (h HardwareSettingListResult) 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 HardwareSettingListResult.
func (h *HardwareSettingListResult) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %v", h, err)
	}
	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: %v", h, err)
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type HardwareSettingProperties.
func (h HardwareSettingProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "deviceId", h.DeviceID)
	populate(objectMap, "diskSpaceInGb", h.DiskSpaceInGb)
	populate(objectMap, "hardwareSku", h.HardwareSKU)
	populate(objectMap, "memoryInGb", h.MemoryInGb)
	populate(objectMap, "nodes", h.Nodes)
	populate(objectMap, "oem", h.Oem)
	populate(objectMap, "provisioningState", h.ProvisioningState)
	populate(objectMap, "solutionBuilderExtension", h.SolutionBuilderExtension)
	populate(objectMap, "totalCores", h.TotalCores)
	populate(objectMap, "versionAtRegistration", h.VersionAtRegistration)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type HardwareSettingProperties.
func (h *HardwareSettingProperties) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %v", h, err)
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "deviceId":
			err = unpopulate(val, "DeviceID", &h.DeviceID)
			delete(rawMsg, key)
		case "diskSpaceInGb":
			err = unpopulate(val, "DiskSpaceInGb", &h.DiskSpaceInGb)
			delete(rawMsg, key)
		case "hardwareSku":
			err = unpopulate(val, "HardwareSKU", &h.HardwareSKU)
			delete(rawMsg, key)
		case "memoryInGb":
			err = unpopulate(val, "MemoryInGb", &h.MemoryInGb)
			delete(rawMsg, key)
		case "nodes":
			err = unpopulate(val, "Nodes", &h.Nodes)
			delete(rawMsg, key)
		case "oem":
			err = unpopulate(val, "Oem", &h.Oem)
			delete(rawMsg, key)
		case "provisioningState":
			err = unpopulate(val, "ProvisioningState", &h.ProvisioningState)
			delete(rawMsg, key)
		case "solutionBuilderExtension":
			err = unpopulate(val, "SolutionBuilderExtension", &h.SolutionBuilderExtension)
			delete(rawMsg, key)
		case "totalCores":
			err = unpopulate(val, "TotalCores", &h.TotalCores)
			delete(rawMsg, key)
		case "versionAtRegistration":
			err = unpopulate(val, "VersionAtRegistration", &h.VersionAtRegistration)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %v", h, err)
		}
	}
	return nil
}

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

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

// MarshalJSON implements the json.Marshaller interface for type ImageDownloadResult.
func (i ImageDownloadResult) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "compatibleVersions", i.CompatibleVersions)
	populate(objectMap, "downloadLink", i.DownloadLink)
	populateTime[datetime.RFC3339](objectMap, "linkExpiry", i.LinkExpiry)
	populate(objectMap, "provisioningState", i.ProvisioningState)
	populateTime[datetime.PlainDate](objectMap, "releaseDate", i.ReleaseDate)
	populate(objectMap, "releaseDisplayName", i.ReleaseDisplayName)
	populate(objectMap, "releaseNotes", i.ReleaseNotes)
	populate(objectMap, "releaseType", i.ReleaseType)
	populate(objectMap, "releaseVersion", i.ReleaseVersion)
	populate(objectMap, "transactionId", i.TransactionID)
	populate(objectMap, "updateProperties", i.UpdateProperties)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type ImageDownloadResult.
func (i *ImageDownloadResult) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %v", i, err)
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "compatibleVersions":
			err = unpopulate(val, "CompatibleVersions", &i.CompatibleVersions)
			delete(rawMsg, key)
		case "downloadLink":
			err = unpopulate(val, "DownloadLink", &i.DownloadLink)
			delete(rawMsg, key)
		case "linkExpiry":
			err = unpopulateTime[datetime.RFC3339](val, "LinkExpiry", &i.LinkExpiry)
			delete(rawMsg, key)
		case "provisioningState":
			err = unpopulate(val, "ProvisioningState", &i.ProvisioningState)
			delete(rawMsg, key)
		case "releaseDate":
			err = unpopulateTime[datetime.PlainDate](val, "ReleaseDate", &i.ReleaseDate)
			delete(rawMsg, key)
		case "releaseDisplayName":
			err = unpopulate(val, "ReleaseDisplayName", &i.ReleaseDisplayName)
			delete(rawMsg, key)
		case "releaseNotes":
			err = unpopulate(val, "ReleaseNotes", &i.ReleaseNotes)
			delete(rawMsg, key)
		case "releaseType":
			err = unpopulate(val, "ReleaseType", &i.ReleaseType)
			delete(rawMsg, key)
		case "releaseVersion":
			err = unpopulate(val, "ReleaseVersion", &i.ReleaseVersion)
			delete(rawMsg, key)
		case "transactionId":
			err = unpopulate(val, "TransactionID", &i.TransactionID)
			delete(rawMsg, key)
		case "updateProperties":
			err = unpopulate(val, "UpdateProperties", &i.UpdateProperties)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %v", i, err)
		}
	}
	return nil
}

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

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

// MarshalJSON implements the json.Marshaller interface for type ImageProperties.
func (i ImageProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "compatibleVersions", i.CompatibleVersions)
	populate(objectMap, "provisioningState", i.ProvisioningState)
	populateTime[datetime.PlainDate](objectMap, "releaseDate", i.ReleaseDate)
	populate(objectMap, "releaseDisplayName", i.ReleaseDisplayName)
	populate(objectMap, "releaseNotes", i.ReleaseNotes)
	populate(objectMap, "releaseType", i.ReleaseType)
	populate(objectMap, "releaseVersion", i.ReleaseVersion)
	populate(objectMap, "updateProperties", i.UpdateProperties)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type ImageProperties.
func (i *ImageProperties) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %v", i, err)
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "compatibleVersions":
			err = unpopulate(val, "CompatibleVersions", &i.CompatibleVersions)
			delete(rawMsg, key)
		case "provisioningState":
			err = unpopulate(val, "ProvisioningState", &i.ProvisioningState)
			delete(rawMsg, key)
		case "releaseDate":
			err = unpopulateTime[datetime.PlainDate](val, "ReleaseDate", &i.ReleaseDate)
			delete(rawMsg, key)
		case "releaseDisplayName":
			err = unpopulate(val, "ReleaseDisplayName", &i.ReleaseDisplayName)
			delete(rawMsg, key)
		case "releaseNotes":
			err = unpopulate(val, "ReleaseNotes", &i.ReleaseNotes)
			delete(rawMsg, key)
		case "releaseType":
			err = unpopulate(val, "ReleaseType", &i.ReleaseType)
			delete(rawMsg, key)
		case "releaseVersion":
			err = unpopulate(val, "ReleaseVersion", &i.ReleaseVersion)
			delete(rawMsg, key)
		case "updateProperties":
			err = unpopulate(val, "UpdateProperties", &i.UpdateProperties)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %v", i, err)
		}
	}
	return nil
}

// MarshalJSON implements the json.Marshaller interface for type ImageUpdateProperties.
func (i ImageUpdateProperties) MarshalJSON() ([]byte, error) {
	objectMap := make(map[string]any)
	populate(objectMap, "agentVersion", i.AgentVersion)
	populate(objectMap, "featureUpdates", i.FeatureUpdates)
	populate(objectMap, "osVersion", i.OSVersion)
	populate(objectMap, "securityUpdates", i.SecurityUpdates)
	populate(objectMap, "systemReboot", i.SystemReboot)
	return json.Marshal(objectMap)
}

// UnmarshalJSON implements the json.Unmarshaller interface for type ImageUpdateProperties.
func (i *ImageUpdateProperties) UnmarshalJSON(data []byte) error {
	var rawMsg map[string]json.RawMessage
	if err := json.Unmarshal(data, &rawMsg); err != nil {
		return fmt.Errorf("unmarshalling type %T: %v", i, err)
	}
	for key, val := range rawMsg {
		var err error
		switch key {
		case "agentVersion":
			err = unpopulate(val, "AgentVersion", &i.AgentVersion)
			delete(rawMsg, key)
		case "featureUpdates":
			err = unpopulate(val, "FeatureUpdates", &i.FeatureUpdates)
			delete(rawMsg, key)
		case "osVersion":
			err = unpopulate(val, "OSVersion", &i.OSVersion)
			delete(rawMsg, key)
		case "securityUpdates":
			err = unpopulate(val, "SecurityUpdates", &i.SecurityUpdates)
			delete(rawMsg, key)
		case "systemReboot":
			err = unpopulate(val, "SystemReboot", &i.SystemReboot)
			delete(rawMsg, key)
		}
		if err != nil {
			return fmt.Errorf("unmarshalling type %T: %v", i, err)
		}
	}
	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: %v", s, err)
	}
	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: %v", s, err)
		}
	}
	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
}
