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

import "encoding/json"

func unmarshalEventModelCustomPropertiesClassification(rawMsg json.RawMessage) (EventModelCustomPropertiesClassification, error) {
	if rawMsg == nil || string(rawMsg) == "null" {
		return nil, nil
	}
	var m map[string]any
	if err := json.Unmarshal(rawMsg, &m); err != nil {
		return nil, err
	}
	var b EventModelCustomPropertiesClassification
	switch m["instanceType"] {
	case "HyperVToAzStackHCI":
		b = &HyperVToAzStackHCIEventModelCustomProperties{}
	case "VMwareToAzStackHCI":
		b = &VMwareToAzStackHCIEventModelCustomProperties{}
	default:
		b = &EventModelCustomProperties{}
	}
	if err := json.Unmarshal(rawMsg, b); err != nil {
		return nil, err
	}
	return b, nil
}

func unmarshalFabricAgentModelCustomPropertiesClassification(rawMsg json.RawMessage) (FabricAgentModelCustomPropertiesClassification, error) {
	if rawMsg == nil || string(rawMsg) == "null" {
		return nil, nil
	}
	var m map[string]any
	if err := json.Unmarshal(rawMsg, &m); err != nil {
		return nil, err
	}
	var b FabricAgentModelCustomPropertiesClassification
	switch m["instanceType"] {
	case "VMware":
		b = &VMwareFabricAgentModelCustomProperties{}
	default:
		b = &FabricAgentModelCustomProperties{}
	}
	if err := json.Unmarshal(rawMsg, b); err != nil {
		return nil, err
	}
	return b, nil
}

func unmarshalFabricModelCustomPropertiesClassification(rawMsg json.RawMessage) (FabricModelCustomPropertiesClassification, error) {
	if rawMsg == nil || string(rawMsg) == "null" {
		return nil, nil
	}
	var m map[string]any
	if err := json.Unmarshal(rawMsg, &m); err != nil {
		return nil, err
	}
	var b FabricModelCustomPropertiesClassification
	switch m["instanceType"] {
	case "AzStackHCI":
		b = &AzStackHCIFabricModelCustomProperties{}
	case "HyperVMigrate":
		b = &HyperVMigrateFabricModelCustomProperties{}
	case "VMwareMigrate":
		b = &VMwareMigrateFabricModelCustomProperties{}
	default:
		b = &FabricModelCustomProperties{}
	}
	if err := json.Unmarshal(rawMsg, b); err != nil {
		return nil, err
	}
	return b, nil
}

func unmarshalJobModelCustomPropertiesClassification(rawMsg json.RawMessage) (JobModelCustomPropertiesClassification, error) {
	if rawMsg == nil || string(rawMsg) == "null" {
		return nil, nil
	}
	var m map[string]any
	if err := json.Unmarshal(rawMsg, &m); err != nil {
		return nil, err
	}
	var b JobModelCustomPropertiesClassification
	switch m["instanceType"] {
	case "FailoverJobDetails":
		b = &FailoverJobModelCustomProperties{}
	case "TestFailoverCleanupJobDetails":
		b = &TestFailoverCleanupJobModelCustomProperties{}
	case "TestFailoverJobDetails":
		b = &TestFailoverJobModelCustomProperties{}
	default:
		b = &JobModelCustomProperties{}
	}
	if err := json.Unmarshal(rawMsg, b); err != nil {
		return nil, err
	}
	return b, nil
}

func unmarshalPlannedFailoverModelCustomPropertiesClassification(rawMsg json.RawMessage) (PlannedFailoverModelCustomPropertiesClassification, error) {
	if rawMsg == nil || string(rawMsg) == "null" {
		return nil, nil
	}
	var m map[string]any
	if err := json.Unmarshal(rawMsg, &m); err != nil {
		return nil, err
	}
	var b PlannedFailoverModelCustomPropertiesClassification
	switch m["instanceType"] {
	case "HyperVToAzStackHCI":
		b = &HyperVToAzStackHCIPlannedFailoverModelCustomProperties{}
	case "VMwareToAzStackHCI":
		b = &VMwareToAzStackHCIPlannedFailoverModelCustomProperties{}
	default:
		b = &PlannedFailoverModelCustomProperties{}
	}
	if err := json.Unmarshal(rawMsg, b); err != nil {
		return nil, err
	}
	return b, nil
}

func unmarshalPolicyModelCustomPropertiesClassification(rawMsg json.RawMessage) (PolicyModelCustomPropertiesClassification, error) {
	if rawMsg == nil || string(rawMsg) == "null" {
		return nil, nil
	}
	var m map[string]any
	if err := json.Unmarshal(rawMsg, &m); err != nil {
		return nil, err
	}
	var b PolicyModelCustomPropertiesClassification
	switch m["instanceType"] {
	case "HyperVToAzStackHCI":
		b = &HyperVToAzStackHCIPolicyModelCustomProperties{}
	case "VMwareToAzStackHCI":
		b = &VMwareToAzStackHCIPolicyModelCustomProperties{}
	default:
		b = &PolicyModelCustomProperties{}
	}
	if err := json.Unmarshal(rawMsg, b); err != nil {
		return nil, err
	}
	return b, nil
}

func unmarshalProtectedItemModelCustomPropertiesClassification(rawMsg json.RawMessage) (ProtectedItemModelCustomPropertiesClassification, error) {
	if rawMsg == nil || string(rawMsg) == "null" {
		return nil, nil
	}
	var m map[string]any
	if err := json.Unmarshal(rawMsg, &m); err != nil {
		return nil, err
	}
	var b ProtectedItemModelCustomPropertiesClassification
	switch m["instanceType"] {
	case "HyperVToAzStackHCI":
		b = &HyperVToAzStackHCIProtectedItemModelCustomProperties{}
	case "VMwareToAzStackHCI":
		b = &VMwareToAzStackHCIProtectedItemModelCustomProperties{}
	default:
		b = &ProtectedItemModelCustomProperties{}
	}
	if err := json.Unmarshal(rawMsg, b); err != nil {
		return nil, err
	}
	return b, nil
}

func unmarshalProtectedItemModelCustomPropertiesUpdateClassification(rawMsg json.RawMessage) (ProtectedItemModelCustomPropertiesUpdateClassification, error) {
	if rawMsg == nil || string(rawMsg) == "null" {
		return nil, nil
	}
	var m map[string]any
	if err := json.Unmarshal(rawMsg, &m); err != nil {
		return nil, err
	}
	var b ProtectedItemModelCustomPropertiesUpdateClassification
	switch m["instanceType"] {
	case "HyperVToAzStackHCI":
		b = &HyperVToAzStackHCIProtectedItemModelCustomPropertiesUpdate{}
	case "VMwareToAzStackHCI":
		b = &VMwareToAzStackHCIProtectedItemModelCustomPropertiesUpdate{}
	default:
		b = &ProtectedItemModelCustomPropertiesUpdate{}
	}
	if err := json.Unmarshal(rawMsg, b); err != nil {
		return nil, err
	}
	return b, nil
}

func unmarshalRecoveryPointModelCustomPropertiesClassification(rawMsg json.RawMessage) (RecoveryPointModelCustomPropertiesClassification, error) {
	if rawMsg == nil || string(rawMsg) == "null" {
		return nil, nil
	}
	var m map[string]any
	if err := json.Unmarshal(rawMsg, &m); err != nil {
		return nil, err
	}
	var b RecoveryPointModelCustomPropertiesClassification
	switch m["instanceType"] {
	case "HyperVToAzStackHCI":
		b = &HyperVToAzStackHCIRecoveryPointModelCustomProperties{}
	case "VMwareToAzStackHCIRecoveryPointModelCustomProperties":
		b = &VMwareToAzStackHCIRecoveryPointModelCustomProperties{}
	default:
		b = &RecoveryPointModelCustomProperties{}
	}
	if err := json.Unmarshal(rawMsg, b); err != nil {
		return nil, err
	}
	return b, nil
}

func unmarshalReplicationExtensionModelCustomPropertiesClassification(rawMsg json.RawMessage) (ReplicationExtensionModelCustomPropertiesClassification, error) {
	if rawMsg == nil || string(rawMsg) == "null" {
		return nil, nil
	}
	var m map[string]any
	if err := json.Unmarshal(rawMsg, &m); err != nil {
		return nil, err
	}
	var b ReplicationExtensionModelCustomPropertiesClassification
	switch m["instanceType"] {
	case "HyperVToAzStackHCI":
		b = &HyperVToAzStackHCIReplicationExtensionModelCustomProperties{}
	case "VMwareToAzStackHCI":
		b = &VMwareToAzStackHCIReplicationExtensionModelCustomProperties{}
	default:
		b = &ReplicationExtensionModelCustomProperties{}
	}
	if err := json.Unmarshal(rawMsg, b); err != nil {
		return nil, err
	}
	return b, nil
}
