// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.

package shared

import (
	"encoding/json"
	"errors"
	"fmt"
	"github.com/airbytehq/terraform-provider-airbyte/internal/sdk/internal/utils"
)

type DestinationPgvectorUpdateSchemasEmbeddingEmbedding5Mode string

const (
	DestinationPgvectorUpdateSchemasEmbeddingEmbedding5ModeOpenaiCompatible DestinationPgvectorUpdateSchemasEmbeddingEmbedding5Mode = "openai_compatible"
)

func (e DestinationPgvectorUpdateSchemasEmbeddingEmbedding5Mode) ToPointer() *DestinationPgvectorUpdateSchemasEmbeddingEmbedding5Mode {
	return &e
}
func (e *DestinationPgvectorUpdateSchemasEmbeddingEmbedding5Mode) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "openai_compatible":
		*e = DestinationPgvectorUpdateSchemasEmbeddingEmbedding5Mode(v)
		return nil
	default:
		return fmt.Errorf("invalid value for DestinationPgvectorUpdateSchemasEmbeddingEmbedding5Mode: %v", v)
	}
}

// DestinationPgvectorUpdateOpenAICompatible - Use a service that's compatible with the OpenAI API to embed text.
type DestinationPgvectorUpdateOpenAICompatible struct {
	APIKey *string `default:"" json:"api_key"`
	// The base URL for your OpenAI-compatible service
	BaseURL string `json:"base_url"`
	// The number of dimensions the embedding model is generating
	Dimensions int64                                                    `json:"dimensions"`
	mode       *DestinationPgvectorUpdateSchemasEmbeddingEmbedding5Mode `const:"openai_compatible" json:"mode"`
	// The name of the model to use for embedding
	ModelName *string `default:"text-embedding-ada-002" json:"model_name"`
}

func (d DestinationPgvectorUpdateOpenAICompatible) MarshalJSON() ([]byte, error) {
	return utils.MarshalJSON(d, "", false)
}

func (d *DestinationPgvectorUpdateOpenAICompatible) UnmarshalJSON(data []byte) error {
	if err := utils.UnmarshalJSON(data, &d, "", false, true); err != nil {
		return err
	}
	return nil
}

func (o *DestinationPgvectorUpdateOpenAICompatible) GetAPIKey() *string {
	if o == nil {
		return nil
	}
	return o.APIKey
}

func (o *DestinationPgvectorUpdateOpenAICompatible) GetBaseURL() string {
	if o == nil {
		return ""
	}
	return o.BaseURL
}

func (o *DestinationPgvectorUpdateOpenAICompatible) GetDimensions() int64 {
	if o == nil {
		return 0
	}
	return o.Dimensions
}

func (o *DestinationPgvectorUpdateOpenAICompatible) GetMode() *DestinationPgvectorUpdateSchemasEmbeddingEmbedding5Mode {
	return DestinationPgvectorUpdateSchemasEmbeddingEmbedding5ModeOpenaiCompatible.ToPointer()
}

func (o *DestinationPgvectorUpdateOpenAICompatible) GetModelName() *string {
	if o == nil {
		return nil
	}
	return o.ModelName
}

type DestinationPgvectorUpdateSchemasEmbeddingEmbeddingMode string

const (
	DestinationPgvectorUpdateSchemasEmbeddingEmbeddingModeAzureOpenai DestinationPgvectorUpdateSchemasEmbeddingEmbeddingMode = "azure_openai"
)

func (e DestinationPgvectorUpdateSchemasEmbeddingEmbeddingMode) ToPointer() *DestinationPgvectorUpdateSchemasEmbeddingEmbeddingMode {
	return &e
}
func (e *DestinationPgvectorUpdateSchemasEmbeddingEmbeddingMode) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "azure_openai":
		*e = DestinationPgvectorUpdateSchemasEmbeddingEmbeddingMode(v)
		return nil
	default:
		return fmt.Errorf("invalid value for DestinationPgvectorUpdateSchemasEmbeddingEmbeddingMode: %v", v)
	}
}

// DestinationPgvectorUpdateAzureOpenAI - Use the Azure-hosted OpenAI API to embed text. This option is using the text-embedding-ada-002 model with 1536 embedding dimensions.
type DestinationPgvectorUpdateAzureOpenAI struct {
	// The base URL for your Azure OpenAI resource.  You can find this in the Azure portal under your Azure OpenAI resource
	APIBase string `json:"api_base"`
	// The deployment for your Azure OpenAI resource.  You can find this in the Azure portal under your Azure OpenAI resource
	Deployment string                                                  `json:"deployment"`
	mode       *DestinationPgvectorUpdateSchemasEmbeddingEmbeddingMode `const:"azure_openai" json:"mode"`
	// The API key for your Azure OpenAI resource.  You can find this in the Azure portal under your Azure OpenAI resource
	OpenaiKey string `json:"openai_key"`
}

func (d DestinationPgvectorUpdateAzureOpenAI) MarshalJSON() ([]byte, error) {
	return utils.MarshalJSON(d, "", false)
}

func (d *DestinationPgvectorUpdateAzureOpenAI) UnmarshalJSON(data []byte) error {
	if err := utils.UnmarshalJSON(data, &d, "", false, true); err != nil {
		return err
	}
	return nil
}

func (o *DestinationPgvectorUpdateAzureOpenAI) GetAPIBase() string {
	if o == nil {
		return ""
	}
	return o.APIBase
}

func (o *DestinationPgvectorUpdateAzureOpenAI) GetDeployment() string {
	if o == nil {
		return ""
	}
	return o.Deployment
}

func (o *DestinationPgvectorUpdateAzureOpenAI) GetMode() *DestinationPgvectorUpdateSchemasEmbeddingEmbeddingMode {
	return DestinationPgvectorUpdateSchemasEmbeddingEmbeddingModeAzureOpenai.ToPointer()
}

func (o *DestinationPgvectorUpdateAzureOpenAI) GetOpenaiKey() string {
	if o == nil {
		return ""
	}
	return o.OpenaiKey
}

type DestinationPgvectorUpdateSchemasEmbeddingMode string

const (
	DestinationPgvectorUpdateSchemasEmbeddingModeFake DestinationPgvectorUpdateSchemasEmbeddingMode = "fake"
)

func (e DestinationPgvectorUpdateSchemasEmbeddingMode) ToPointer() *DestinationPgvectorUpdateSchemasEmbeddingMode {
	return &e
}
func (e *DestinationPgvectorUpdateSchemasEmbeddingMode) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "fake":
		*e = DestinationPgvectorUpdateSchemasEmbeddingMode(v)
		return nil
	default:
		return fmt.Errorf("invalid value for DestinationPgvectorUpdateSchemasEmbeddingMode: %v", v)
	}
}

// DestinationPgvectorUpdateFake - Use a fake embedding made out of random vectors with 1536 embedding dimensions. This is useful for testing the data pipeline without incurring any costs.
type DestinationPgvectorUpdateFake struct {
	mode *DestinationPgvectorUpdateSchemasEmbeddingMode `const:"fake" json:"mode"`
}

func (d DestinationPgvectorUpdateFake) MarshalJSON() ([]byte, error) {
	return utils.MarshalJSON(d, "", false)
}

func (d *DestinationPgvectorUpdateFake) UnmarshalJSON(data []byte) error {
	if err := utils.UnmarshalJSON(data, &d, "", false, true); err != nil {
		return err
	}
	return nil
}

func (o *DestinationPgvectorUpdateFake) GetMode() *DestinationPgvectorUpdateSchemasEmbeddingMode {
	return DestinationPgvectorUpdateSchemasEmbeddingModeFake.ToPointer()
}

type DestinationPgvectorUpdateSchemasMode string

const (
	DestinationPgvectorUpdateSchemasModeCohere DestinationPgvectorUpdateSchemasMode = "cohere"
)

func (e DestinationPgvectorUpdateSchemasMode) ToPointer() *DestinationPgvectorUpdateSchemasMode {
	return &e
}
func (e *DestinationPgvectorUpdateSchemasMode) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "cohere":
		*e = DestinationPgvectorUpdateSchemasMode(v)
		return nil
	default:
		return fmt.Errorf("invalid value for DestinationPgvectorUpdateSchemasMode: %v", v)
	}
}

// DestinationPgvectorUpdateCohere - Use the Cohere API to embed text.
type DestinationPgvectorUpdateCohere struct {
	CohereKey string                                `json:"cohere_key"`
	mode      *DestinationPgvectorUpdateSchemasMode `const:"cohere" json:"mode"`
}

func (d DestinationPgvectorUpdateCohere) MarshalJSON() ([]byte, error) {
	return utils.MarshalJSON(d, "", false)
}

func (d *DestinationPgvectorUpdateCohere) UnmarshalJSON(data []byte) error {
	if err := utils.UnmarshalJSON(data, &d, "", false, true); err != nil {
		return err
	}
	return nil
}

func (o *DestinationPgvectorUpdateCohere) GetCohereKey() string {
	if o == nil {
		return ""
	}
	return o.CohereKey
}

func (o *DestinationPgvectorUpdateCohere) GetMode() *DestinationPgvectorUpdateSchemasMode {
	return DestinationPgvectorUpdateSchemasModeCohere.ToPointer()
}

type DestinationPgvectorUpdateMode string

const (
	DestinationPgvectorUpdateModeOpenai DestinationPgvectorUpdateMode = "openai"
)

func (e DestinationPgvectorUpdateMode) ToPointer() *DestinationPgvectorUpdateMode {
	return &e
}
func (e *DestinationPgvectorUpdateMode) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "openai":
		*e = DestinationPgvectorUpdateMode(v)
		return nil
	default:
		return fmt.Errorf("invalid value for DestinationPgvectorUpdateMode: %v", v)
	}
}

// DestinationPgvectorUpdateOpenAI - Use the OpenAI API to embed text. This option is using the text-embedding-ada-002 model with 1536 embedding dimensions.
type DestinationPgvectorUpdateOpenAI struct {
	mode      *DestinationPgvectorUpdateMode `const:"openai" json:"mode"`
	OpenaiKey string                         `json:"openai_key"`
}

func (d DestinationPgvectorUpdateOpenAI) MarshalJSON() ([]byte, error) {
	return utils.MarshalJSON(d, "", false)
}

func (d *DestinationPgvectorUpdateOpenAI) UnmarshalJSON(data []byte) error {
	if err := utils.UnmarshalJSON(data, &d, "", false, true); err != nil {
		return err
	}
	return nil
}

func (o *DestinationPgvectorUpdateOpenAI) GetMode() *DestinationPgvectorUpdateMode {
	return DestinationPgvectorUpdateModeOpenai.ToPointer()
}

func (o *DestinationPgvectorUpdateOpenAI) GetOpenaiKey() string {
	if o == nil {
		return ""
	}
	return o.OpenaiKey
}

type DestinationPgvectorUpdateEmbeddingType string

const (
	DestinationPgvectorUpdateEmbeddingTypeDestinationPgvectorUpdateOpenAI           DestinationPgvectorUpdateEmbeddingType = "destination-pgvector-update_OpenAI"
	DestinationPgvectorUpdateEmbeddingTypeDestinationPgvectorUpdateCohere           DestinationPgvectorUpdateEmbeddingType = "destination-pgvector-update_Cohere"
	DestinationPgvectorUpdateEmbeddingTypeDestinationPgvectorUpdateFake             DestinationPgvectorUpdateEmbeddingType = "destination-pgvector-update_Fake"
	DestinationPgvectorUpdateEmbeddingTypeDestinationPgvectorUpdateAzureOpenAI      DestinationPgvectorUpdateEmbeddingType = "destination-pgvector-update_Azure OpenAI"
	DestinationPgvectorUpdateEmbeddingTypeDestinationPgvectorUpdateOpenAICompatible DestinationPgvectorUpdateEmbeddingType = "destination-pgvector-update_OpenAI-compatible"
)

// DestinationPgvectorUpdateEmbedding - Embedding configuration
type DestinationPgvectorUpdateEmbedding struct {
	DestinationPgvectorUpdateOpenAI           *DestinationPgvectorUpdateOpenAI           `queryParam:"inline"`
	DestinationPgvectorUpdateCohere           *DestinationPgvectorUpdateCohere           `queryParam:"inline"`
	DestinationPgvectorUpdateFake             *DestinationPgvectorUpdateFake             `queryParam:"inline"`
	DestinationPgvectorUpdateAzureOpenAI      *DestinationPgvectorUpdateAzureOpenAI      `queryParam:"inline"`
	DestinationPgvectorUpdateOpenAICompatible *DestinationPgvectorUpdateOpenAICompatible `queryParam:"inline"`

	Type DestinationPgvectorUpdateEmbeddingType
}

func CreateDestinationPgvectorUpdateEmbeddingDestinationPgvectorUpdateOpenAI(destinationPgvectorUpdateOpenAI DestinationPgvectorUpdateOpenAI) DestinationPgvectorUpdateEmbedding {
	typ := DestinationPgvectorUpdateEmbeddingTypeDestinationPgvectorUpdateOpenAI

	return DestinationPgvectorUpdateEmbedding{
		DestinationPgvectorUpdateOpenAI: &destinationPgvectorUpdateOpenAI,
		Type:                            typ,
	}
}

func CreateDestinationPgvectorUpdateEmbeddingDestinationPgvectorUpdateCohere(destinationPgvectorUpdateCohere DestinationPgvectorUpdateCohere) DestinationPgvectorUpdateEmbedding {
	typ := DestinationPgvectorUpdateEmbeddingTypeDestinationPgvectorUpdateCohere

	return DestinationPgvectorUpdateEmbedding{
		DestinationPgvectorUpdateCohere: &destinationPgvectorUpdateCohere,
		Type:                            typ,
	}
}

func CreateDestinationPgvectorUpdateEmbeddingDestinationPgvectorUpdateFake(destinationPgvectorUpdateFake DestinationPgvectorUpdateFake) DestinationPgvectorUpdateEmbedding {
	typ := DestinationPgvectorUpdateEmbeddingTypeDestinationPgvectorUpdateFake

	return DestinationPgvectorUpdateEmbedding{
		DestinationPgvectorUpdateFake: &destinationPgvectorUpdateFake,
		Type:                          typ,
	}
}

func CreateDestinationPgvectorUpdateEmbeddingDestinationPgvectorUpdateAzureOpenAI(destinationPgvectorUpdateAzureOpenAI DestinationPgvectorUpdateAzureOpenAI) DestinationPgvectorUpdateEmbedding {
	typ := DestinationPgvectorUpdateEmbeddingTypeDestinationPgvectorUpdateAzureOpenAI

	return DestinationPgvectorUpdateEmbedding{
		DestinationPgvectorUpdateAzureOpenAI: &destinationPgvectorUpdateAzureOpenAI,
		Type:                                 typ,
	}
}

func CreateDestinationPgvectorUpdateEmbeddingDestinationPgvectorUpdateOpenAICompatible(destinationPgvectorUpdateOpenAICompatible DestinationPgvectorUpdateOpenAICompatible) DestinationPgvectorUpdateEmbedding {
	typ := DestinationPgvectorUpdateEmbeddingTypeDestinationPgvectorUpdateOpenAICompatible

	return DestinationPgvectorUpdateEmbedding{
		DestinationPgvectorUpdateOpenAICompatible: &destinationPgvectorUpdateOpenAICompatible,
		Type: typ,
	}
}

func (u *DestinationPgvectorUpdateEmbedding) UnmarshalJSON(data []byte) error {

	var destinationPgvectorUpdateFake DestinationPgvectorUpdateFake = DestinationPgvectorUpdateFake{}
	if err := utils.UnmarshalJSON(data, &destinationPgvectorUpdateFake, "", true, true); err == nil {
		u.DestinationPgvectorUpdateFake = &destinationPgvectorUpdateFake
		u.Type = DestinationPgvectorUpdateEmbeddingTypeDestinationPgvectorUpdateFake
		return nil
	}

	var destinationPgvectorUpdateOpenAI DestinationPgvectorUpdateOpenAI = DestinationPgvectorUpdateOpenAI{}
	if err := utils.UnmarshalJSON(data, &destinationPgvectorUpdateOpenAI, "", true, true); err == nil {
		u.DestinationPgvectorUpdateOpenAI = &destinationPgvectorUpdateOpenAI
		u.Type = DestinationPgvectorUpdateEmbeddingTypeDestinationPgvectorUpdateOpenAI
		return nil
	}

	var destinationPgvectorUpdateCohere DestinationPgvectorUpdateCohere = DestinationPgvectorUpdateCohere{}
	if err := utils.UnmarshalJSON(data, &destinationPgvectorUpdateCohere, "", true, true); err == nil {
		u.DestinationPgvectorUpdateCohere = &destinationPgvectorUpdateCohere
		u.Type = DestinationPgvectorUpdateEmbeddingTypeDestinationPgvectorUpdateCohere
		return nil
	}

	var destinationPgvectorUpdateAzureOpenAI DestinationPgvectorUpdateAzureOpenAI = DestinationPgvectorUpdateAzureOpenAI{}
	if err := utils.UnmarshalJSON(data, &destinationPgvectorUpdateAzureOpenAI, "", true, true); err == nil {
		u.DestinationPgvectorUpdateAzureOpenAI = &destinationPgvectorUpdateAzureOpenAI
		u.Type = DestinationPgvectorUpdateEmbeddingTypeDestinationPgvectorUpdateAzureOpenAI
		return nil
	}

	var destinationPgvectorUpdateOpenAICompatible DestinationPgvectorUpdateOpenAICompatible = DestinationPgvectorUpdateOpenAICompatible{}
	if err := utils.UnmarshalJSON(data, &destinationPgvectorUpdateOpenAICompatible, "", true, true); err == nil {
		u.DestinationPgvectorUpdateOpenAICompatible = &destinationPgvectorUpdateOpenAICompatible
		u.Type = DestinationPgvectorUpdateEmbeddingTypeDestinationPgvectorUpdateOpenAICompatible
		return nil
	}

	return fmt.Errorf("could not unmarshal `%s` into any supported union types for DestinationPgvectorUpdateEmbedding", string(data))
}

func (u DestinationPgvectorUpdateEmbedding) MarshalJSON() ([]byte, error) {
	if u.DestinationPgvectorUpdateOpenAI != nil {
		return utils.MarshalJSON(u.DestinationPgvectorUpdateOpenAI, "", true)
	}

	if u.DestinationPgvectorUpdateCohere != nil {
		return utils.MarshalJSON(u.DestinationPgvectorUpdateCohere, "", true)
	}

	if u.DestinationPgvectorUpdateFake != nil {
		return utils.MarshalJSON(u.DestinationPgvectorUpdateFake, "", true)
	}

	if u.DestinationPgvectorUpdateAzureOpenAI != nil {
		return utils.MarshalJSON(u.DestinationPgvectorUpdateAzureOpenAI, "", true)
	}

	if u.DestinationPgvectorUpdateOpenAICompatible != nil {
		return utils.MarshalJSON(u.DestinationPgvectorUpdateOpenAICompatible, "", true)
	}

	return nil, errors.New("could not marshal union type DestinationPgvectorUpdateEmbedding: all fields are null")
}

type DestinationPgvectorUpdateCredentials struct {
	// Enter the password you want to use to access the database
	Password string `json:"password"`
}

func (o *DestinationPgvectorUpdateCredentials) GetPassword() string {
	if o == nil {
		return ""
	}
	return o.Password
}

// DestinationPgvectorUpdatePostgresConnection - Postgres can be used to store vector data and retrieve embeddings.
type DestinationPgvectorUpdatePostgresConnection struct {
	Credentials DestinationPgvectorUpdateCredentials `json:"credentials"`
	// Enter the name of the database that you want to sync data into
	Database string `json:"database"`
	// Enter the name of the default schema
	DefaultSchema *string `default:"public" json:"default_schema"`
	// Enter the account name you want to use to access the database.
	Host string `json:"host"`
	// Enter the port you want to use to access the database
	Port *int64 `default:"5432" json:"port"`
	// Enter the name of the user you want to use to access the database
	Username string `json:"username"`
}

func (d DestinationPgvectorUpdatePostgresConnection) MarshalJSON() ([]byte, error) {
	return utils.MarshalJSON(d, "", false)
}

func (d *DestinationPgvectorUpdatePostgresConnection) UnmarshalJSON(data []byte) error {
	if err := utils.UnmarshalJSON(data, &d, "", false, false); err != nil {
		return err
	}
	return nil
}

func (o *DestinationPgvectorUpdatePostgresConnection) GetCredentials() DestinationPgvectorUpdateCredentials {
	if o == nil {
		return DestinationPgvectorUpdateCredentials{}
	}
	return o.Credentials
}

func (o *DestinationPgvectorUpdatePostgresConnection) GetDatabase() string {
	if o == nil {
		return ""
	}
	return o.Database
}

func (o *DestinationPgvectorUpdatePostgresConnection) GetDefaultSchema() *string {
	if o == nil {
		return nil
	}
	return o.DefaultSchema
}

func (o *DestinationPgvectorUpdatePostgresConnection) GetHost() string {
	if o == nil {
		return ""
	}
	return o.Host
}

func (o *DestinationPgvectorUpdatePostgresConnection) GetPort() *int64 {
	if o == nil {
		return nil
	}
	return o.Port
}

func (o *DestinationPgvectorUpdatePostgresConnection) GetUsername() string {
	if o == nil {
		return ""
	}
	return o.Username
}

type DestinationPgvectorUpdateFieldNameMappingConfigModel struct {
	// The field name in the source
	FromField string `json:"from_field"`
	// The field name to use in the destination
	ToField string `json:"to_field"`
}

func (o *DestinationPgvectorUpdateFieldNameMappingConfigModel) GetFromField() string {
	if o == nil {
		return ""
	}
	return o.FromField
}

func (o *DestinationPgvectorUpdateFieldNameMappingConfigModel) GetToField() string {
	if o == nil {
		return ""
	}
	return o.ToField
}

// DestinationPgvectorUpdateLanguage - Split code in suitable places based on the programming language
type DestinationPgvectorUpdateLanguage string

const (
	DestinationPgvectorUpdateLanguageCpp      DestinationPgvectorUpdateLanguage = "cpp"
	DestinationPgvectorUpdateLanguageGo       DestinationPgvectorUpdateLanguage = "go"
	DestinationPgvectorUpdateLanguageJava     DestinationPgvectorUpdateLanguage = "java"
	DestinationPgvectorUpdateLanguageJs       DestinationPgvectorUpdateLanguage = "js"
	DestinationPgvectorUpdateLanguagePhp      DestinationPgvectorUpdateLanguage = "php"
	DestinationPgvectorUpdateLanguageProto    DestinationPgvectorUpdateLanguage = "proto"
	DestinationPgvectorUpdateLanguagePython   DestinationPgvectorUpdateLanguage = "python"
	DestinationPgvectorUpdateLanguageRst      DestinationPgvectorUpdateLanguage = "rst"
	DestinationPgvectorUpdateLanguageRuby     DestinationPgvectorUpdateLanguage = "ruby"
	DestinationPgvectorUpdateLanguageRust     DestinationPgvectorUpdateLanguage = "rust"
	DestinationPgvectorUpdateLanguageScala    DestinationPgvectorUpdateLanguage = "scala"
	DestinationPgvectorUpdateLanguageSwift    DestinationPgvectorUpdateLanguage = "swift"
	DestinationPgvectorUpdateLanguageMarkdown DestinationPgvectorUpdateLanguage = "markdown"
	DestinationPgvectorUpdateLanguageLatex    DestinationPgvectorUpdateLanguage = "latex"
	DestinationPgvectorUpdateLanguageHTML     DestinationPgvectorUpdateLanguage = "html"
	DestinationPgvectorUpdateLanguageSol      DestinationPgvectorUpdateLanguage = "sol"
)

func (e DestinationPgvectorUpdateLanguage) ToPointer() *DestinationPgvectorUpdateLanguage {
	return &e
}
func (e *DestinationPgvectorUpdateLanguage) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "cpp":
		fallthrough
	case "go":
		fallthrough
	case "java":
		fallthrough
	case "js":
		fallthrough
	case "php":
		fallthrough
	case "proto":
		fallthrough
	case "python":
		fallthrough
	case "rst":
		fallthrough
	case "ruby":
		fallthrough
	case "rust":
		fallthrough
	case "scala":
		fallthrough
	case "swift":
		fallthrough
	case "markdown":
		fallthrough
	case "latex":
		fallthrough
	case "html":
		fallthrough
	case "sol":
		*e = DestinationPgvectorUpdateLanguage(v)
		return nil
	default:
		return fmt.Errorf("invalid value for DestinationPgvectorUpdateLanguage: %v", v)
	}
}

type DestinationPgvectorUpdateSchemasProcessingTextSplitterTextSplitterMode string

const (
	DestinationPgvectorUpdateSchemasProcessingTextSplitterTextSplitterModeCode DestinationPgvectorUpdateSchemasProcessingTextSplitterTextSplitterMode = "code"
)

func (e DestinationPgvectorUpdateSchemasProcessingTextSplitterTextSplitterMode) ToPointer() *DestinationPgvectorUpdateSchemasProcessingTextSplitterTextSplitterMode {
	return &e
}
func (e *DestinationPgvectorUpdateSchemasProcessingTextSplitterTextSplitterMode) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "code":
		*e = DestinationPgvectorUpdateSchemasProcessingTextSplitterTextSplitterMode(v)
		return nil
	default:
		return fmt.Errorf("invalid value for DestinationPgvectorUpdateSchemasProcessingTextSplitterTextSplitterMode: %v", v)
	}
}

// DestinationPgvectorUpdateByProgrammingLanguage - Split the text by suitable delimiters based on the programming language. This is useful for splitting code into chunks.
type DestinationPgvectorUpdateByProgrammingLanguage struct {
	// Split code in suitable places based on the programming language
	Language DestinationPgvectorUpdateLanguage                                       `json:"language"`
	mode     *DestinationPgvectorUpdateSchemasProcessingTextSplitterTextSplitterMode `const:"code" json:"mode"`
}

func (d DestinationPgvectorUpdateByProgrammingLanguage) MarshalJSON() ([]byte, error) {
	return utils.MarshalJSON(d, "", false)
}

func (d *DestinationPgvectorUpdateByProgrammingLanguage) UnmarshalJSON(data []byte) error {
	if err := utils.UnmarshalJSON(data, &d, "", false, true); err != nil {
		return err
	}
	return nil
}

func (o *DestinationPgvectorUpdateByProgrammingLanguage) GetLanguage() DestinationPgvectorUpdateLanguage {
	if o == nil {
		return DestinationPgvectorUpdateLanguage("")
	}
	return o.Language
}

func (o *DestinationPgvectorUpdateByProgrammingLanguage) GetMode() *DestinationPgvectorUpdateSchemasProcessingTextSplitterTextSplitterMode {
	return DestinationPgvectorUpdateSchemasProcessingTextSplitterTextSplitterModeCode.ToPointer()
}

type DestinationPgvectorUpdateSchemasProcessingTextSplitterMode string

const (
	DestinationPgvectorUpdateSchemasProcessingTextSplitterModeMarkdown DestinationPgvectorUpdateSchemasProcessingTextSplitterMode = "markdown"
)

func (e DestinationPgvectorUpdateSchemasProcessingTextSplitterMode) ToPointer() *DestinationPgvectorUpdateSchemasProcessingTextSplitterMode {
	return &e
}
func (e *DestinationPgvectorUpdateSchemasProcessingTextSplitterMode) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "markdown":
		*e = DestinationPgvectorUpdateSchemasProcessingTextSplitterMode(v)
		return nil
	default:
		return fmt.Errorf("invalid value for DestinationPgvectorUpdateSchemasProcessingTextSplitterMode: %v", v)
	}
}

// DestinationPgvectorUpdateByMarkdownHeader - Split the text by Markdown headers down to the specified header level. If the chunk size fits multiple sections, they will be combined into a single chunk.
type DestinationPgvectorUpdateByMarkdownHeader struct {
	mode *DestinationPgvectorUpdateSchemasProcessingTextSplitterMode `const:"markdown" json:"mode"`
	// Level of markdown headers to split text fields by. Headings down to the specified level will be used as split points
	SplitLevel *int64 `default:"1" json:"split_level"`
}

func (d DestinationPgvectorUpdateByMarkdownHeader) MarshalJSON() ([]byte, error) {
	return utils.MarshalJSON(d, "", false)
}

func (d *DestinationPgvectorUpdateByMarkdownHeader) UnmarshalJSON(data []byte) error {
	if err := utils.UnmarshalJSON(data, &d, "", false, true); err != nil {
		return err
	}
	return nil
}

func (o *DestinationPgvectorUpdateByMarkdownHeader) GetMode() *DestinationPgvectorUpdateSchemasProcessingTextSplitterMode {
	return DestinationPgvectorUpdateSchemasProcessingTextSplitterModeMarkdown.ToPointer()
}

func (o *DestinationPgvectorUpdateByMarkdownHeader) GetSplitLevel() *int64 {
	if o == nil {
		return nil
	}
	return o.SplitLevel
}

type DestinationPgvectorUpdateSchemasProcessingMode string

const (
	DestinationPgvectorUpdateSchemasProcessingModeSeparator DestinationPgvectorUpdateSchemasProcessingMode = "separator"
)

func (e DestinationPgvectorUpdateSchemasProcessingMode) ToPointer() *DestinationPgvectorUpdateSchemasProcessingMode {
	return &e
}
func (e *DestinationPgvectorUpdateSchemasProcessingMode) UnmarshalJSON(data []byte) error {
	var v string
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}
	switch v {
	case "separator":
		*e = DestinationPgvectorUpdateSchemasProcessingMode(v)
		return nil
	default:
		return fmt.Errorf("invalid value for DestinationPgvectorUpdateSchemasProcessingMode: %v", v)
	}
}

// DestinationPgvectorUpdateBySeparator - Split the text by the list of separators until the chunk size is reached, using the earlier mentioned separators where possible. This is useful for splitting text fields by paragraphs, sentences, words, etc.
type DestinationPgvectorUpdateBySeparator struct {
	// Whether to keep the separator in the resulting chunks
	KeepSeparator *bool                                           `default:"false" json:"keep_separator"`
	mode          *DestinationPgvectorUpdateSchemasProcessingMode `const:"separator" json:"mode"`
	// List of separator strings to split text fields by. The separator itself needs to be wrapped in double quotes, e.g. to split by the dot character, use ".". To split by a newline, use "\n".
	Separators []string `json:"separators,omitempty"`
}

func (d DestinationPgvectorUpdateBySeparator) MarshalJSON() ([]byte, error) {
	return utils.MarshalJSON(d, "", false)
}

func (d *DestinationPgvectorUpdateBySeparator) UnmarshalJSON(data []byte) error {
	if err := utils.UnmarshalJSON(data, &d, "", false, true); err != nil {
		return err
	}
	return nil
}

func (o *DestinationPgvectorUpdateBySeparator) GetKeepSeparator() *bool {
	if o == nil {
		return nil
	}
	return o.KeepSeparator
}

func (o *DestinationPgvectorUpdateBySeparator) GetMode() *DestinationPgvectorUpdateSchemasProcessingMode {
	return DestinationPgvectorUpdateSchemasProcessingModeSeparator.ToPointer()
}

func (o *DestinationPgvectorUpdateBySeparator) GetSeparators() []string {
	if o == nil {
		return nil
	}
	return o.Separators
}

type DestinationPgvectorUpdateTextSplitterType string

const (
	DestinationPgvectorUpdateTextSplitterTypeDestinationPgvectorUpdateBySeparator           DestinationPgvectorUpdateTextSplitterType = "destination-pgvector-update_By Separator"
	DestinationPgvectorUpdateTextSplitterTypeDestinationPgvectorUpdateByMarkdownHeader      DestinationPgvectorUpdateTextSplitterType = "destination-pgvector-update_By Markdown header"
	DestinationPgvectorUpdateTextSplitterTypeDestinationPgvectorUpdateByProgrammingLanguage DestinationPgvectorUpdateTextSplitterType = "destination-pgvector-update_By Programming Language"
)

// DestinationPgvectorUpdateTextSplitter - Split text fields into chunks based on the specified method.
type DestinationPgvectorUpdateTextSplitter struct {
	DestinationPgvectorUpdateBySeparator           *DestinationPgvectorUpdateBySeparator           `queryParam:"inline"`
	DestinationPgvectorUpdateByMarkdownHeader      *DestinationPgvectorUpdateByMarkdownHeader      `queryParam:"inline"`
	DestinationPgvectorUpdateByProgrammingLanguage *DestinationPgvectorUpdateByProgrammingLanguage `queryParam:"inline"`

	Type DestinationPgvectorUpdateTextSplitterType
}

func CreateDestinationPgvectorUpdateTextSplitterDestinationPgvectorUpdateBySeparator(destinationPgvectorUpdateBySeparator DestinationPgvectorUpdateBySeparator) DestinationPgvectorUpdateTextSplitter {
	typ := DestinationPgvectorUpdateTextSplitterTypeDestinationPgvectorUpdateBySeparator

	return DestinationPgvectorUpdateTextSplitter{
		DestinationPgvectorUpdateBySeparator: &destinationPgvectorUpdateBySeparator,
		Type:                                 typ,
	}
}

func CreateDestinationPgvectorUpdateTextSplitterDestinationPgvectorUpdateByMarkdownHeader(destinationPgvectorUpdateByMarkdownHeader DestinationPgvectorUpdateByMarkdownHeader) DestinationPgvectorUpdateTextSplitter {
	typ := DestinationPgvectorUpdateTextSplitterTypeDestinationPgvectorUpdateByMarkdownHeader

	return DestinationPgvectorUpdateTextSplitter{
		DestinationPgvectorUpdateByMarkdownHeader: &destinationPgvectorUpdateByMarkdownHeader,
		Type: typ,
	}
}

func CreateDestinationPgvectorUpdateTextSplitterDestinationPgvectorUpdateByProgrammingLanguage(destinationPgvectorUpdateByProgrammingLanguage DestinationPgvectorUpdateByProgrammingLanguage) DestinationPgvectorUpdateTextSplitter {
	typ := DestinationPgvectorUpdateTextSplitterTypeDestinationPgvectorUpdateByProgrammingLanguage

	return DestinationPgvectorUpdateTextSplitter{
		DestinationPgvectorUpdateByProgrammingLanguage: &destinationPgvectorUpdateByProgrammingLanguage,
		Type: typ,
	}
}

func (u *DestinationPgvectorUpdateTextSplitter) UnmarshalJSON(data []byte) error {

	var destinationPgvectorUpdateByMarkdownHeader DestinationPgvectorUpdateByMarkdownHeader = DestinationPgvectorUpdateByMarkdownHeader{}
	if err := utils.UnmarshalJSON(data, &destinationPgvectorUpdateByMarkdownHeader, "", true, true); err == nil {
		u.DestinationPgvectorUpdateByMarkdownHeader = &destinationPgvectorUpdateByMarkdownHeader
		u.Type = DestinationPgvectorUpdateTextSplitterTypeDestinationPgvectorUpdateByMarkdownHeader
		return nil
	}

	var destinationPgvectorUpdateByProgrammingLanguage DestinationPgvectorUpdateByProgrammingLanguage = DestinationPgvectorUpdateByProgrammingLanguage{}
	if err := utils.UnmarshalJSON(data, &destinationPgvectorUpdateByProgrammingLanguage, "", true, true); err == nil {
		u.DestinationPgvectorUpdateByProgrammingLanguage = &destinationPgvectorUpdateByProgrammingLanguage
		u.Type = DestinationPgvectorUpdateTextSplitterTypeDestinationPgvectorUpdateByProgrammingLanguage
		return nil
	}

	var destinationPgvectorUpdateBySeparator DestinationPgvectorUpdateBySeparator = DestinationPgvectorUpdateBySeparator{}
	if err := utils.UnmarshalJSON(data, &destinationPgvectorUpdateBySeparator, "", true, true); err == nil {
		u.DestinationPgvectorUpdateBySeparator = &destinationPgvectorUpdateBySeparator
		u.Type = DestinationPgvectorUpdateTextSplitterTypeDestinationPgvectorUpdateBySeparator
		return nil
	}

	return fmt.Errorf("could not unmarshal `%s` into any supported union types for DestinationPgvectorUpdateTextSplitter", string(data))
}

func (u DestinationPgvectorUpdateTextSplitter) MarshalJSON() ([]byte, error) {
	if u.DestinationPgvectorUpdateBySeparator != nil {
		return utils.MarshalJSON(u.DestinationPgvectorUpdateBySeparator, "", true)
	}

	if u.DestinationPgvectorUpdateByMarkdownHeader != nil {
		return utils.MarshalJSON(u.DestinationPgvectorUpdateByMarkdownHeader, "", true)
	}

	if u.DestinationPgvectorUpdateByProgrammingLanguage != nil {
		return utils.MarshalJSON(u.DestinationPgvectorUpdateByProgrammingLanguage, "", true)
	}

	return nil, errors.New("could not marshal union type DestinationPgvectorUpdateTextSplitter: all fields are null")
}

type DestinationPgvectorUpdateProcessingConfigModel struct {
	// Size of overlap between chunks in tokens to store in vector store to better capture relevant context
	ChunkOverlap *int64 `default:"0" json:"chunk_overlap"`
	// Size of chunks in tokens to store in vector store (make sure it is not too big for the context if your LLM)
	ChunkSize int64 `json:"chunk_size"`
	// List of fields to rename. Not applicable for nested fields, but can be used to rename fields already flattened via dot notation.
	FieldNameMappings []DestinationPgvectorUpdateFieldNameMappingConfigModel `json:"field_name_mappings,omitempty"`
	// List of fields in the record that should be stored as metadata. The field list is applied to all streams in the same way and non-existing fields are ignored. If none are defined, all fields are considered metadata fields. When specifying text fields, you can access nested fields in the record by using dot notation, e.g. `user.name` will access the `name` field in the `user` object. It's also possible to use wildcards to access all fields in an object, e.g. `users.*.name` will access all `names` fields in all entries of the `users` array. When specifying nested paths, all matching values are flattened into an array set to a field named by the path.
	MetadataFields []string `json:"metadata_fields,omitempty"`
	// List of fields in the record that should be used to calculate the embedding. The field list is applied to all streams in the same way and non-existing fields are ignored. If none are defined, all fields are considered text fields. When specifying text fields, you can access nested fields in the record by using dot notation, e.g. `user.name` will access the `name` field in the `user` object. It's also possible to use wildcards to access all fields in an object, e.g. `users.*.name` will access all `names` fields in all entries of the `users` array.
	TextFields []string `json:"text_fields,omitempty"`
	// Split text fields into chunks based on the specified method.
	TextSplitter *DestinationPgvectorUpdateTextSplitter `json:"text_splitter,omitempty"`
}

func (d DestinationPgvectorUpdateProcessingConfigModel) MarshalJSON() ([]byte, error) {
	return utils.MarshalJSON(d, "", false)
}

func (d *DestinationPgvectorUpdateProcessingConfigModel) UnmarshalJSON(data []byte) error {
	if err := utils.UnmarshalJSON(data, &d, "", false, false); err != nil {
		return err
	}
	return nil
}

func (o *DestinationPgvectorUpdateProcessingConfigModel) GetChunkOverlap() *int64 {
	if o == nil {
		return nil
	}
	return o.ChunkOverlap
}

func (o *DestinationPgvectorUpdateProcessingConfigModel) GetChunkSize() int64 {
	if o == nil {
		return 0
	}
	return o.ChunkSize
}

func (o *DestinationPgvectorUpdateProcessingConfigModel) GetFieldNameMappings() []DestinationPgvectorUpdateFieldNameMappingConfigModel {
	if o == nil {
		return nil
	}
	return o.FieldNameMappings
}

func (o *DestinationPgvectorUpdateProcessingConfigModel) GetMetadataFields() []string {
	if o == nil {
		return nil
	}
	return o.MetadataFields
}

func (o *DestinationPgvectorUpdateProcessingConfigModel) GetTextFields() []string {
	if o == nil {
		return nil
	}
	return o.TextFields
}

func (o *DestinationPgvectorUpdateProcessingConfigModel) GetTextSplitter() *DestinationPgvectorUpdateTextSplitter {
	if o == nil {
		return nil
	}
	return o.TextSplitter
}

// DestinationPgvectorUpdate - The configuration model for the Vector DB based destinations. This model is used to generate the UI for the destination configuration,
// as well as to provide type safety for the configuration passed to the destination.
//
// The configuration model is composed of four parts:
// * Processing configuration
// * Embedding configuration
// * Indexing configuration
// * Advanced configuration
//
// Processing, embedding and advanced configuration are provided by this base class, while the indexing configuration is provided by the destination connector in the sub class.
type DestinationPgvectorUpdate struct {
	// Embedding configuration
	Embedding DestinationPgvectorUpdateEmbedding `json:"embedding"`
	// Postgres can be used to store vector data and retrieve embeddings.
	Indexing DestinationPgvectorUpdatePostgresConnection `json:"indexing"`
	// Do not store the text that gets embedded along with the vector and the metadata in the destination. If set to true, only the vector and the metadata will be stored - in this case raw text for LLM use cases needs to be retrieved from another source.
	OmitRawText *bool                                          `default:"false" json:"omit_raw_text"`
	Processing  DestinationPgvectorUpdateProcessingConfigModel `json:"processing"`
}

func (d DestinationPgvectorUpdate) MarshalJSON() ([]byte, error) {
	return utils.MarshalJSON(d, "", false)
}

func (d *DestinationPgvectorUpdate) UnmarshalJSON(data []byte) error {
	if err := utils.UnmarshalJSON(data, &d, "", false, false); err != nil {
		return err
	}
	return nil
}

func (o *DestinationPgvectorUpdate) GetEmbedding() DestinationPgvectorUpdateEmbedding {
	if o == nil {
		return DestinationPgvectorUpdateEmbedding{}
	}
	return o.Embedding
}

func (o *DestinationPgvectorUpdate) GetIndexing() DestinationPgvectorUpdatePostgresConnection {
	if o == nil {
		return DestinationPgvectorUpdatePostgresConnection{}
	}
	return o.Indexing
}

func (o *DestinationPgvectorUpdate) GetOmitRawText() *bool {
	if o == nil {
		return nil
	}
	return o.OmitRawText
}

func (o *DestinationPgvectorUpdate) GetProcessing() DestinationPgvectorUpdateProcessingConfigModel {
	if o == nil {
		return DestinationPgvectorUpdateProcessingConfigModel{}
	}
	return o.Processing
}
