//go:build go1.18
// +build go1.18

// 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) AutoRest Code Generator. DO NOT EDIT.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.

package azopenai

import "encoding/json"

func unmarshalOnYourDataAuthenticationOptionsClassification(rawMsg json.RawMessage) (OnYourDataAuthenticationOptionsClassification, 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 OnYourDataAuthenticationOptionsClassification
	switch m["type"] {
	case string(OnYourDataAuthenticationTypeAccessToken):
		b = &OnYourDataAccessTokenAuthenticationOptions{}
	case string(OnYourDataAuthenticationTypeAPIKey):
		b = &OnYourDataAPIKeyAuthenticationOptions{}
	case string(OnYourDataAuthenticationTypeConnectionString):
		b = &OnYourDataConnectionStringAuthenticationOptions{}
	case string(OnYourDataAuthenticationTypeEncodedAPIKey):
		b = &OnYourDataEncodedAPIKeyAuthenticationOptions{}
	case string(OnYourDataAuthenticationTypeKeyAndKeyID):
		b = &OnYourDataKeyAndKeyIDAuthenticationOptions{}
	case string(OnYourDataAuthenticationTypeSystemAssignedManagedIdentity):
		b = &OnYourDataSystemAssignedManagedIdentityAuthenticationOptions{}
	case string(OnYourDataAuthenticationTypeUserAssignedManagedIdentity):
		b = &OnYourDataUserAssignedManagedIdentityAuthenticationOptions{}
	case string(OnYourDataAuthenticationTypeUsernameAndPassword):
		b = &OnYourDataUsernameAndPasswordAuthenticationOptions{}
	default:
		b = &OnYourDataAuthenticationOptions{}
	}
	if err := json.Unmarshal(rawMsg, b); err != nil {
		return nil, err
	}
	return b, nil
}

func unmarshalOnYourDataVectorSearchAuthenticationOptionsClassification(rawMsg json.RawMessage) (OnYourDataVectorSearchAuthenticationOptionsClassification, 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 OnYourDataVectorSearchAuthenticationOptionsClassification
	switch m["type"] {
	case string(OnYourDataVectorSearchAuthenticationTypeAccessToken):
		b = &OnYourDataVectorSearchAccessTokenAuthenticationOptions{}
	case string(OnYourDataVectorSearchAuthenticationTypeAPIKey):
		b = &OnYourDataVectorSearchAPIKeyAuthenticationOptions{}
	default:
		b = &OnYourDataVectorSearchAuthenticationOptions{}
	}
	if err := json.Unmarshal(rawMsg, b); err != nil {
		return nil, err
	}
	return b, nil
}

func unmarshalOnYourDataVectorizationSourceClassification(rawMsg json.RawMessage) (OnYourDataVectorizationSourceClassification, 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 OnYourDataVectorizationSourceClassification
	switch m["type"] {
	case string(OnYourDataVectorizationSourceTypeDeploymentName):
		b = &OnYourDataDeploymentNameVectorizationSource{}
	case string(OnYourDataVectorizationSourceTypeEndpoint):
		b = &OnYourDataEndpointVectorizationSource{}
	case string(OnYourDataVectorizationSourceTypeIntegrated):
		b = &OnYourDataIntegratedVectorizationSource{}
	case string(OnYourDataVectorizationSourceTypeModelID):
		b = &OnYourDataModelIDVectorizationSource{}
	default:
		b = &OnYourDataVectorizationSource{}
	}
	if err := json.Unmarshal(rawMsg, b); err != nil {
		return nil, err
	}
	return b, nil
}
