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

package shared

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

type Typesense string

const (
	TypesenseTypesense Typesense = "typesense"
)

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

type DestinationTypesense struct {
	// Typesense API Key
	APIKey string `json:"api_key"`
	// How many documents should be imported together. Default 1000
	BatchSize *int64 `json:"batch_size,omitempty"`
	// Hostname of the Typesense instance without protocol. Accept multiple hosts separated by comma.
	Host string `json:"host"`
	// Path of the Typesense instance. Default is none
	Path *string `json:"path,omitempty"`
	// Port of the Typesense instance. Ex: 8108, 80, 443. Default is 8108
	Port *string `json:"port,omitempty"`
	// Protocol of the Typesense instance. Ex: http or https. Default is https
	Protocol        *string   `json:"protocol,omitempty"`
	destinationType Typesense `const:"typesense" json:"destinationType"`
}

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

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

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

func (o *DestinationTypesense) GetBatchSize() *int64 {
	if o == nil {
		return nil
	}
	return o.BatchSize
}

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

func (o *DestinationTypesense) GetPath() *string {
	if o == nil {
		return nil
	}
	return o.Path
}

func (o *DestinationTypesense) GetPort() *string {
	if o == nil {
		return nil
	}
	return o.Port
}

func (o *DestinationTypesense) GetProtocol() *string {
	if o == nil {
		return nil
	}
	return o.Protocol
}

func (o *DestinationTypesense) GetDestinationType() Typesense {
	return TypesenseTypesense
}
