// Code generated by Azure.Iot.Operations.ProtocolCompilerLib v0.10.0.0; DO NOT EDIT.
package schemaregistry

import (
	"encoding/json"
	"errors"
)

type SchemaRegistryErrorTarget int32

const (
	SchemaRegistryErrorTargetDescriptionProperty SchemaRegistryErrorTarget = iota
	SchemaRegistryErrorTargetDisplayNameProperty SchemaRegistryErrorTarget = iota
	SchemaRegistryErrorTargetFormatProperty SchemaRegistryErrorTarget = iota
	SchemaRegistryErrorTargetNameProperty SchemaRegistryErrorTarget = iota
	SchemaRegistryErrorTargetSchemaArmResource SchemaRegistryErrorTarget = iota
	SchemaRegistryErrorTargetSchemaContentProperty SchemaRegistryErrorTarget = iota
	SchemaRegistryErrorTargetSchemaRegistryArmResource SchemaRegistryErrorTarget = iota
	SchemaRegistryErrorTargetSchemaTypeProperty SchemaRegistryErrorTarget = iota
	SchemaRegistryErrorTargetSchemaVersionArmResource SchemaRegistryErrorTarget = iota
	SchemaRegistryErrorTargetTagsProperty SchemaRegistryErrorTarget = iota
	SchemaRegistryErrorTargetVersionProperty SchemaRegistryErrorTarget = iota
)

func (v SchemaRegistryErrorTarget) String() string {
	switch v {
	case SchemaRegistryErrorTargetDescriptionProperty:
		return "DescriptionProperty"
	case SchemaRegistryErrorTargetDisplayNameProperty:
		return "DisplayNameProperty"
	case SchemaRegistryErrorTargetFormatProperty:
		return "FormatProperty"
	case SchemaRegistryErrorTargetNameProperty:
		return "NameProperty"
	case SchemaRegistryErrorTargetSchemaArmResource:
		return "SchemaArmResource"
	case SchemaRegistryErrorTargetSchemaContentProperty:
		return "SchemaContentProperty"
	case SchemaRegistryErrorTargetSchemaRegistryArmResource:
		return "SchemaRegistryArmResource"
	case SchemaRegistryErrorTargetSchemaTypeProperty:
		return "SchemaTypeProperty"
	case SchemaRegistryErrorTargetSchemaVersionArmResource:
		return "SchemaVersionArmResource"
	case SchemaRegistryErrorTargetTagsProperty:
		return "TagsProperty"
	case SchemaRegistryErrorTargetVersionProperty:
		return "VersionProperty"
	default:
		return ""
	}
}

func (v SchemaRegistryErrorTarget) MarshalJSON() ([]byte, error) {
	var s string
	switch v {
	case SchemaRegistryErrorTargetDescriptionProperty:
		s = "Description"
	case SchemaRegistryErrorTargetDisplayNameProperty:
		s = "DisplayName"
	case SchemaRegistryErrorTargetFormatProperty:
		s = "Format"
	case SchemaRegistryErrorTargetNameProperty:
		s = "Name"
	case SchemaRegistryErrorTargetSchemaArmResource:
		s = "SchemaArmResource"
	case SchemaRegistryErrorTargetSchemaContentProperty:
		s = "SchemaContent"
	case SchemaRegistryErrorTargetSchemaRegistryArmResource:
		s = "SchemaRegistryResource"
	case SchemaRegistryErrorTargetSchemaTypeProperty:
		s = "SchemaType"
	case SchemaRegistryErrorTargetSchemaVersionArmResource:
		s = "SchemaVersionArmResource"
	case SchemaRegistryErrorTargetTagsProperty:
		s = "Tags"
	case SchemaRegistryErrorTargetVersionProperty:
		s = "Version"
	default:
		return []byte{}, errors.New("unable to marshal unrecognized enum value to JSON")
	}

	return json.Marshal(s)
}

func (v *SchemaRegistryErrorTarget) UnmarshalJSON(b []byte) error {
	var s string
	if err := json.Unmarshal(b, &s); err != nil {
		return err
	}

	switch s {
	case "Description":
		*v = SchemaRegistryErrorTargetDescriptionProperty
	case "DisplayName":
		*v = SchemaRegistryErrorTargetDisplayNameProperty
	case "Format":
		*v = SchemaRegistryErrorTargetFormatProperty
	case "Name":
		*v = SchemaRegistryErrorTargetNameProperty
	case "SchemaArmResource":
		*v = SchemaRegistryErrorTargetSchemaArmResource
	case "SchemaContent":
		*v = SchemaRegistryErrorTargetSchemaContentProperty
	case "SchemaRegistryResource":
		*v = SchemaRegistryErrorTargetSchemaRegistryArmResource
	case "SchemaType":
		*v = SchemaRegistryErrorTargetSchemaTypeProperty
	case "SchemaVersionArmResource":
		*v = SchemaRegistryErrorTargetSchemaVersionArmResource
	case "Tags":
		*v = SchemaRegistryErrorTargetTagsProperty
	case "Version":
		*v = SchemaRegistryErrorTargetVersionProperty
	default:
		return errors.New("unable to unmarshal unrecognized enum value from JSON")
	}

	return nil
}
