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

import "encoding/json"

func unmarshalDrillPropertiesClassification(rawMsg json.RawMessage) (DrillPropertiesClassification, 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 DrillPropertiesClassification
	switch m["drillType"] {
	case string(DrillTypeRegional):
		b = &RegionalDrillProperties{}
	case string(DrillTypeZonal):
		b = &ZonalDrillProperties{}
	default:
		b = &DrillProperties{}
	}
	if err := json.Unmarshal(rawMsg, b); err != nil {
		return nil, err
	}
	return b, nil
}

func unmarshalRecoveryGroupBaseActionClassification(rawMsg json.RawMessage) (RecoveryGroupBaseActionClassification, 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 RecoveryGroupBaseActionClassification
	switch m["type"] {
	case string(RecoveryGroupActionTypeCustomRunbook):
		b = &RecoveryGroupCustomRunbookAction{}
	case string(RecoveryGroupActionTypeManualAction):
		b = &RecoveryGroupManualAction{}
	default:
		b = &RecoveryGroupBaseAction{}
	}
	if err := json.Unmarshal(rawMsg, b); err != nil {
		return nil, err
	}
	return b, nil
}

func unmarshalRecoveryGroupBaseActionClassificationArray(rawMsg json.RawMessage) ([]RecoveryGroupBaseActionClassification, error) {
	if rawMsg == nil || string(rawMsg) == "null" {
		return nil, nil
	}
	var rawMessages []json.RawMessage
	if err := json.Unmarshal(rawMsg, &rawMessages); err != nil {
		return nil, err
	}
	fArray := make([]RecoveryGroupBaseActionClassification, len(rawMessages))
	for index, rawMessage := range rawMessages {
		f, err := unmarshalRecoveryGroupBaseActionClassification(rawMessage)
		if err != nil {
			return nil, err
		}
		fArray[index] = f
	}
	return fArray, nil
}

func unmarshalResourceBaseProtectionSolutionSettingClassification(rawMsg json.RawMessage) (ResourceBaseProtectionSolutionSettingClassification, 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 ResourceBaseProtectionSolutionSettingClassification
	switch m["protectionSolutionType"] {
	case string(ResourceProtectionSolutionTypeAzureNative):
		b = &ResourceNativeProtectionSolutionSetting{}
	case string(ResourceProtectionSolutionTypeAzureSiteRecovery):
		b = &ResourceSiteRecoveryProtectionSetting{}
	case string(ResourceProtectionSolutionTypeCustomRunbook):
		b = &ResourceCustomProtectionSetting{}
	default:
		b = &ResourceBaseProtectionSolutionSetting{}
	}
	if err := json.Unmarshal(rawMsg, b); err != nil {
		return nil, err
	}
	return b, nil
}
