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

import "encoding/json"

func unmarshalConnectionPropertiesV2Classification(rawMsg json.RawMessage) (ConnectionPropertiesV2Classification, 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 ConnectionPropertiesV2Classification
	switch m["authType"] {
	case string(ConnectionAuthTypeAAD):
		b = &AADAuthTypeConnectionProperties{}
	case string(ConnectionAuthTypeAccessKey):
		b = &AccessKeyAuthTypeConnectionProperties{}
	case string(ConnectionAuthTypeAccountKey):
		b = &AccountKeyAuthTypeConnectionProperties{}
	case string(ConnectionAuthTypeAPIKey):
		b = &APIKeyAuthConnectionProperties{}
	case string(ConnectionAuthTypeCustomKeys):
		b = &CustomKeysConnectionProperties{}
	case string(ConnectionAuthTypeManagedIdentity):
		b = &ManagedIdentityAuthTypeConnectionProperties{}
	case string(ConnectionAuthTypeNone):
		b = &NoneAuthTypeConnectionProperties{}
	case string(ConnectionAuthTypeOAuth2):
		b = &OAuth2AuthTypeConnectionProperties{}
	case string(ConnectionAuthTypePAT):
		b = &PATAuthTypeConnectionProperties{}
	case string(ConnectionAuthTypeSAS):
		b = &SASAuthTypeConnectionProperties{}
	case string(ConnectionAuthTypeServicePrincipal):
		b = &ServicePrincipalAuthTypeConnectionProperties{}
	case string(ConnectionAuthTypeUsernamePassword):
		b = &UsernamePasswordAuthTypeConnectionProperties{}
	default:
		b = &ConnectionPropertiesV2{}
	}
	if err := json.Unmarshal(rawMsg, b); err != nil {
		return nil, err
	}
	return b, nil
}
