// 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 SourceSapHanaEnterpriseSchemasCursorMethod string

const (
	SourceSapHanaEnterpriseSchemasCursorMethodCdc SourceSapHanaEnterpriseSchemasCursorMethod = "cdc"
)

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

// SourceSapHanaEnterpriseInvalidCDCPositionBehaviorAdvanced - Determines whether Airbyte should fail or re-sync data in case of an stale/invalid cursor value in the mined logs. If 'Fail sync' is chosen, a user will have to manually reset the connection before being able to continue syncing data. If 'Re-sync data' is chosen, Airbyte will automatically trigger a refresh but could lead to higher cloud costs and data loss.
type SourceSapHanaEnterpriseInvalidCDCPositionBehaviorAdvanced string

const (
	SourceSapHanaEnterpriseInvalidCDCPositionBehaviorAdvancedFailSync   SourceSapHanaEnterpriseInvalidCDCPositionBehaviorAdvanced = "Fail sync"
	SourceSapHanaEnterpriseInvalidCDCPositionBehaviorAdvancedReSyncData SourceSapHanaEnterpriseInvalidCDCPositionBehaviorAdvanced = "Re-sync data"
)

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

// SourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC - <i>Recommended</i> - Incrementally reads new inserts, updates, and deletes using change data capture feature. This must be enabled on your database.
type SourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC struct {
	CursorMethod *SourceSapHanaEnterpriseSchemasCursorMethod `default:"cdc" json:"cursor_method"`
	// The amount of time an initial load is allowed to continue for before catching up on CDC events.
	InitialLoadTimeoutHours *int64 `default:"8" json:"initial_load_timeout_hours"`
	// Determines whether Airbyte should fail or re-sync data in case of an stale/invalid cursor value in the mined logs. If 'Fail sync' is chosen, a user will have to manually reset the connection before being able to continue syncing data. If 'Re-sync data' is chosen, Airbyte will automatically trigger a refresh but could lead to higher cloud costs and data loss.
	InvalidCdcCursorPositionBehavior *SourceSapHanaEnterpriseInvalidCDCPositionBehaviorAdvanced `default:"Fail sync" json:"invalid_cdc_cursor_position_behavior"`
	AdditionalProperties             any                                                        `additionalProperties:"true" json:"-"`
}

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

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

func (o *SourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC) GetCursorMethod() *SourceSapHanaEnterpriseSchemasCursorMethod {
	if o == nil {
		return nil
	}
	return o.CursorMethod
}

func (o *SourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC) GetInitialLoadTimeoutHours() *int64 {
	if o == nil {
		return nil
	}
	return o.InitialLoadTimeoutHours
}

func (o *SourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC) GetInvalidCdcCursorPositionBehavior() *SourceSapHanaEnterpriseInvalidCDCPositionBehaviorAdvanced {
	if o == nil {
		return nil
	}
	return o.InvalidCdcCursorPositionBehavior
}

func (o *SourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC) GetAdditionalProperties() any {
	if o == nil {
		return nil
	}
	return o.AdditionalProperties
}

type SourceSapHanaEnterpriseCursorMethod string

const (
	SourceSapHanaEnterpriseCursorMethodUserDefined SourceSapHanaEnterpriseCursorMethod = "user_defined"
)

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

// SourceSapHanaEnterpriseScanChangesWithUserDefinedCursor - Incrementally detects new inserts and updates using the <a href="https://docs.airbyte.com/understanding-airbyte/connections/incremental-append/#user-defined-cursor">cursor column</a> chosen when configuring a connection (e.g. created_at, updated_at).
type SourceSapHanaEnterpriseScanChangesWithUserDefinedCursor struct {
	CursorMethod         *SourceSapHanaEnterpriseCursorMethod `default:"user_defined" json:"cursor_method"`
	AdditionalProperties any                                  `additionalProperties:"true" json:"-"`
}

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

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

func (o *SourceSapHanaEnterpriseScanChangesWithUserDefinedCursor) GetCursorMethod() *SourceSapHanaEnterpriseCursorMethod {
	if o == nil {
		return nil
	}
	return o.CursorMethod
}

func (o *SourceSapHanaEnterpriseScanChangesWithUserDefinedCursor) GetAdditionalProperties() any {
	if o == nil {
		return nil
	}
	return o.AdditionalProperties
}

type SourceSapHanaEnterpriseUpdateMethodType string

const (
	SourceSapHanaEnterpriseUpdateMethodTypeSourceSapHanaEnterpriseScanChangesWithUserDefinedCursor     SourceSapHanaEnterpriseUpdateMethodType = "source-sap-hana-enterprise_Scan Changes with User Defined Cursor"
	SourceSapHanaEnterpriseUpdateMethodTypeSourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC SourceSapHanaEnterpriseUpdateMethodType = "source-sap-hana-enterprise_Read Changes using Change Data Capture (CDC)"
)

// SourceSapHanaEnterpriseUpdateMethod - Configures how data is extracted from the database.
type SourceSapHanaEnterpriseUpdateMethod struct {
	SourceSapHanaEnterpriseScanChangesWithUserDefinedCursor     *SourceSapHanaEnterpriseScanChangesWithUserDefinedCursor     `queryParam:"inline"`
	SourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC *SourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC `queryParam:"inline"`

	Type SourceSapHanaEnterpriseUpdateMethodType
}

func CreateSourceSapHanaEnterpriseUpdateMethodSourceSapHanaEnterpriseScanChangesWithUserDefinedCursor(sourceSapHanaEnterpriseScanChangesWithUserDefinedCursor SourceSapHanaEnterpriseScanChangesWithUserDefinedCursor) SourceSapHanaEnterpriseUpdateMethod {
	typ := SourceSapHanaEnterpriseUpdateMethodTypeSourceSapHanaEnterpriseScanChangesWithUserDefinedCursor

	return SourceSapHanaEnterpriseUpdateMethod{
		SourceSapHanaEnterpriseScanChangesWithUserDefinedCursor: &sourceSapHanaEnterpriseScanChangesWithUserDefinedCursor,
		Type: typ,
	}
}

func CreateSourceSapHanaEnterpriseUpdateMethodSourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC(sourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC SourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC) SourceSapHanaEnterpriseUpdateMethod {
	typ := SourceSapHanaEnterpriseUpdateMethodTypeSourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC

	return SourceSapHanaEnterpriseUpdateMethod{
		SourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC: &sourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC,
		Type: typ,
	}
}

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

	var sourceSapHanaEnterpriseScanChangesWithUserDefinedCursor SourceSapHanaEnterpriseScanChangesWithUserDefinedCursor = SourceSapHanaEnterpriseScanChangesWithUserDefinedCursor{}
	if err := utils.UnmarshalJSON(data, &sourceSapHanaEnterpriseScanChangesWithUserDefinedCursor, "", true, true); err == nil {
		u.SourceSapHanaEnterpriseScanChangesWithUserDefinedCursor = &sourceSapHanaEnterpriseScanChangesWithUserDefinedCursor
		u.Type = SourceSapHanaEnterpriseUpdateMethodTypeSourceSapHanaEnterpriseScanChangesWithUserDefinedCursor
		return nil
	}

	var sourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC SourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC = SourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC{}
	if err := utils.UnmarshalJSON(data, &sourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC, "", true, true); err == nil {
		u.SourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC = &sourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC
		u.Type = SourceSapHanaEnterpriseUpdateMethodTypeSourceSapHanaEnterpriseReadChangesUsingChangeDataCaptureCDC
		return nil
	}

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

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

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

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

type SourceSapHanaEnterpriseSchemasEncryptionEncryptionMethod string

const (
	SourceSapHanaEnterpriseSchemasEncryptionEncryptionMethodEncryptedVerifyCertificate SourceSapHanaEnterpriseSchemasEncryptionEncryptionMethod = "encrypted_verify_certificate"
)

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

// SourceSapHanaEnterpriseTLSEncryptedVerifyCertificate - Verify and use the certificate provided by the server.
type SourceSapHanaEnterpriseTLSEncryptedVerifyCertificate struct {
	EncryptionMethod *SourceSapHanaEnterpriseSchemasEncryptionEncryptionMethod `default:"encrypted_verify_certificate" json:"encryption_method"`
	// Privacy Enhanced Mail (PEM) files are concatenated certificate containers frequently used in certificate installations.
	SslCertificate       string `json:"ssl_certificate"`
	AdditionalProperties any    `additionalProperties:"true" json:"-"`
}

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

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

func (o *SourceSapHanaEnterpriseTLSEncryptedVerifyCertificate) GetEncryptionMethod() *SourceSapHanaEnterpriseSchemasEncryptionEncryptionMethod {
	if o == nil {
		return nil
	}
	return o.EncryptionMethod
}

func (o *SourceSapHanaEnterpriseTLSEncryptedVerifyCertificate) GetSslCertificate() string {
	if o == nil {
		return ""
	}
	return o.SslCertificate
}

func (o *SourceSapHanaEnterpriseTLSEncryptedVerifyCertificate) GetAdditionalProperties() any {
	if o == nil {
		return nil
	}
	return o.AdditionalProperties
}

// SourceSapHanaEnterpriseEncryptionAlgorithm - This parameter defines what encryption algorithm is used.
type SourceSapHanaEnterpriseEncryptionAlgorithm string

const (
	SourceSapHanaEnterpriseEncryptionAlgorithmAes256      SourceSapHanaEnterpriseEncryptionAlgorithm = "AES256"
	SourceSapHanaEnterpriseEncryptionAlgorithmRc456       SourceSapHanaEnterpriseEncryptionAlgorithm = "RC4_56"
	SourceSapHanaEnterpriseEncryptionAlgorithmThreeDes168 SourceSapHanaEnterpriseEncryptionAlgorithm = "3DES168"
)

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

type SourceSapHanaEnterpriseSchemasEncryptionMethod string

const (
	SourceSapHanaEnterpriseSchemasEncryptionMethodClientNne SourceSapHanaEnterpriseSchemasEncryptionMethod = "client_nne"
)

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

// SourceSapHanaEnterpriseNativeNetworkEncryptionNNE - The native network encryption gives you the ability to encrypt database connections, without the configuration overhead of TCP/IP and SSL/TLS and without the need to open and listen on different ports.
type SourceSapHanaEnterpriseNativeNetworkEncryptionNNE struct {
	// This parameter defines what encryption algorithm is used.
	EncryptionAlgorithm  *SourceSapHanaEnterpriseEncryptionAlgorithm     `default:"AES256" json:"encryption_algorithm"`
	EncryptionMethod     *SourceSapHanaEnterpriseSchemasEncryptionMethod `default:"client_nne" json:"encryption_method"`
	AdditionalProperties any                                             `additionalProperties:"true" json:"-"`
}

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

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

func (o *SourceSapHanaEnterpriseNativeNetworkEncryptionNNE) GetEncryptionAlgorithm() *SourceSapHanaEnterpriseEncryptionAlgorithm {
	if o == nil {
		return nil
	}
	return o.EncryptionAlgorithm
}

func (o *SourceSapHanaEnterpriseNativeNetworkEncryptionNNE) GetEncryptionMethod() *SourceSapHanaEnterpriseSchemasEncryptionMethod {
	if o == nil {
		return nil
	}
	return o.EncryptionMethod
}

func (o *SourceSapHanaEnterpriseNativeNetworkEncryptionNNE) GetAdditionalProperties() any {
	if o == nil {
		return nil
	}
	return o.AdditionalProperties
}

type SourceSapHanaEnterpriseEncryptionMethod string

const (
	SourceSapHanaEnterpriseEncryptionMethodUnencrypted SourceSapHanaEnterpriseEncryptionMethod = "unencrypted"
)

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

// SourceSapHanaEnterpriseUnencrypted - Data transfer will not be encrypted.
type SourceSapHanaEnterpriseUnencrypted struct {
	EncryptionMethod     *SourceSapHanaEnterpriseEncryptionMethod `default:"unencrypted" json:"encryption_method"`
	AdditionalProperties any                                      `additionalProperties:"true" json:"-"`
}

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

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

func (o *SourceSapHanaEnterpriseUnencrypted) GetEncryptionMethod() *SourceSapHanaEnterpriseEncryptionMethod {
	if o == nil {
		return nil
	}
	return o.EncryptionMethod
}

func (o *SourceSapHanaEnterpriseUnencrypted) GetAdditionalProperties() any {
	if o == nil {
		return nil
	}
	return o.AdditionalProperties
}

type SourceSapHanaEnterpriseEncryptionType string

const (
	SourceSapHanaEnterpriseEncryptionTypeSourceSapHanaEnterpriseUnencrypted                   SourceSapHanaEnterpriseEncryptionType = "source-sap-hana-enterprise_Unencrypted"
	SourceSapHanaEnterpriseEncryptionTypeSourceSapHanaEnterpriseNativeNetworkEncryptionNNE    SourceSapHanaEnterpriseEncryptionType = "source-sap-hana-enterprise_Native Network Encryption (NNE)"
	SourceSapHanaEnterpriseEncryptionTypeSourceSapHanaEnterpriseTLSEncryptedVerifyCertificate SourceSapHanaEnterpriseEncryptionType = "source-sap-hana-enterprise_TLS Encrypted (verify certificate)"
)

// SourceSapHanaEnterpriseEncryption - The encryption method with is used when communicating with the database.
type SourceSapHanaEnterpriseEncryption struct {
	SourceSapHanaEnterpriseUnencrypted                   *SourceSapHanaEnterpriseUnencrypted                   `queryParam:"inline"`
	SourceSapHanaEnterpriseNativeNetworkEncryptionNNE    *SourceSapHanaEnterpriseNativeNetworkEncryptionNNE    `queryParam:"inline"`
	SourceSapHanaEnterpriseTLSEncryptedVerifyCertificate *SourceSapHanaEnterpriseTLSEncryptedVerifyCertificate `queryParam:"inline"`

	Type SourceSapHanaEnterpriseEncryptionType
}

func CreateSourceSapHanaEnterpriseEncryptionSourceSapHanaEnterpriseUnencrypted(sourceSapHanaEnterpriseUnencrypted SourceSapHanaEnterpriseUnencrypted) SourceSapHanaEnterpriseEncryption {
	typ := SourceSapHanaEnterpriseEncryptionTypeSourceSapHanaEnterpriseUnencrypted

	return SourceSapHanaEnterpriseEncryption{
		SourceSapHanaEnterpriseUnencrypted: &sourceSapHanaEnterpriseUnencrypted,
		Type:                               typ,
	}
}

func CreateSourceSapHanaEnterpriseEncryptionSourceSapHanaEnterpriseNativeNetworkEncryptionNNE(sourceSapHanaEnterpriseNativeNetworkEncryptionNNE SourceSapHanaEnterpriseNativeNetworkEncryptionNNE) SourceSapHanaEnterpriseEncryption {
	typ := SourceSapHanaEnterpriseEncryptionTypeSourceSapHanaEnterpriseNativeNetworkEncryptionNNE

	return SourceSapHanaEnterpriseEncryption{
		SourceSapHanaEnterpriseNativeNetworkEncryptionNNE: &sourceSapHanaEnterpriseNativeNetworkEncryptionNNE,
		Type: typ,
	}
}

func CreateSourceSapHanaEnterpriseEncryptionSourceSapHanaEnterpriseTLSEncryptedVerifyCertificate(sourceSapHanaEnterpriseTLSEncryptedVerifyCertificate SourceSapHanaEnterpriseTLSEncryptedVerifyCertificate) SourceSapHanaEnterpriseEncryption {
	typ := SourceSapHanaEnterpriseEncryptionTypeSourceSapHanaEnterpriseTLSEncryptedVerifyCertificate

	return SourceSapHanaEnterpriseEncryption{
		SourceSapHanaEnterpriseTLSEncryptedVerifyCertificate: &sourceSapHanaEnterpriseTLSEncryptedVerifyCertificate,
		Type: typ,
	}
}

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

	var sourceSapHanaEnterpriseUnencrypted SourceSapHanaEnterpriseUnencrypted = SourceSapHanaEnterpriseUnencrypted{}
	if err := utils.UnmarshalJSON(data, &sourceSapHanaEnterpriseUnencrypted, "", true, true); err == nil {
		u.SourceSapHanaEnterpriseUnencrypted = &sourceSapHanaEnterpriseUnencrypted
		u.Type = SourceSapHanaEnterpriseEncryptionTypeSourceSapHanaEnterpriseUnencrypted
		return nil
	}

	var sourceSapHanaEnterpriseNativeNetworkEncryptionNNE SourceSapHanaEnterpriseNativeNetworkEncryptionNNE = SourceSapHanaEnterpriseNativeNetworkEncryptionNNE{}
	if err := utils.UnmarshalJSON(data, &sourceSapHanaEnterpriseNativeNetworkEncryptionNNE, "", true, true); err == nil {
		u.SourceSapHanaEnterpriseNativeNetworkEncryptionNNE = &sourceSapHanaEnterpriseNativeNetworkEncryptionNNE
		u.Type = SourceSapHanaEnterpriseEncryptionTypeSourceSapHanaEnterpriseNativeNetworkEncryptionNNE
		return nil
	}

	var sourceSapHanaEnterpriseTLSEncryptedVerifyCertificate SourceSapHanaEnterpriseTLSEncryptedVerifyCertificate = SourceSapHanaEnterpriseTLSEncryptedVerifyCertificate{}
	if err := utils.UnmarshalJSON(data, &sourceSapHanaEnterpriseTLSEncryptedVerifyCertificate, "", true, true); err == nil {
		u.SourceSapHanaEnterpriseTLSEncryptedVerifyCertificate = &sourceSapHanaEnterpriseTLSEncryptedVerifyCertificate
		u.Type = SourceSapHanaEnterpriseEncryptionTypeSourceSapHanaEnterpriseTLSEncryptedVerifyCertificate
		return nil
	}

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

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

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

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

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

type SourceSapHanaEnterpriseSchemasTunnelMethodTunnelMethod string

const (
	SourceSapHanaEnterpriseSchemasTunnelMethodTunnelMethodSSHPasswordAuth SourceSapHanaEnterpriseSchemasTunnelMethodTunnelMethod = "SSH_PASSWORD_AUTH"
)

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

// SourceSapHanaEnterprisePasswordAuthentication - Connect through a jump server tunnel host using username and password authentication
type SourceSapHanaEnterprisePasswordAuthentication struct {
	// Hostname of the jump server host that allows inbound ssh tunnel.
	TunnelHost   string                                                  `json:"tunnel_host"`
	TunnelMethod *SourceSapHanaEnterpriseSchemasTunnelMethodTunnelMethod `default:"SSH_PASSWORD_AUTH" json:"tunnel_method"`
	// Port on the proxy/jump server that accepts inbound ssh connections.
	TunnelPort *int64 `default:"22" json:"tunnel_port"`
	// OS-level username for logging into the jump server host
	TunnelUser string `json:"tunnel_user"`
	// OS-level password for logging into the jump server host
	TunnelUserPassword   string `json:"tunnel_user_password"`
	AdditionalProperties any    `additionalProperties:"true" json:"-"`
}

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

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

func (o *SourceSapHanaEnterprisePasswordAuthentication) GetTunnelHost() string {
	if o == nil {
		return ""
	}
	return o.TunnelHost
}

func (o *SourceSapHanaEnterprisePasswordAuthentication) GetTunnelMethod() *SourceSapHanaEnterpriseSchemasTunnelMethodTunnelMethod {
	if o == nil {
		return nil
	}
	return o.TunnelMethod
}

func (o *SourceSapHanaEnterprisePasswordAuthentication) GetTunnelPort() *int64 {
	if o == nil {
		return nil
	}
	return o.TunnelPort
}

func (o *SourceSapHanaEnterprisePasswordAuthentication) GetTunnelUser() string {
	if o == nil {
		return ""
	}
	return o.TunnelUser
}

func (o *SourceSapHanaEnterprisePasswordAuthentication) GetTunnelUserPassword() string {
	if o == nil {
		return ""
	}
	return o.TunnelUserPassword
}

func (o *SourceSapHanaEnterprisePasswordAuthentication) GetAdditionalProperties() any {
	if o == nil {
		return nil
	}
	return o.AdditionalProperties
}

type SourceSapHanaEnterpriseSchemasTunnelMethod string

const (
	SourceSapHanaEnterpriseSchemasTunnelMethodSSHKeyAuth SourceSapHanaEnterpriseSchemasTunnelMethod = "SSH_KEY_AUTH"
)

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

// SourceSapHanaEnterpriseSSHKeyAuthentication - Connect through a jump server tunnel host using username and ssh key
type SourceSapHanaEnterpriseSSHKeyAuthentication struct {
	// OS-level user account ssh key credentials in RSA PEM format ( created with ssh-keygen -t rsa -m PEM -f myuser_rsa )
	SSHKey string `json:"ssh_key"`
	// Hostname of the jump server host that allows inbound ssh tunnel.
	TunnelHost   string                                      `json:"tunnel_host"`
	TunnelMethod *SourceSapHanaEnterpriseSchemasTunnelMethod `default:"SSH_KEY_AUTH" json:"tunnel_method"`
	// Port on the proxy/jump server that accepts inbound ssh connections.
	TunnelPort *int64 `default:"22" json:"tunnel_port"`
	// OS-level username for logging into the jump server host
	TunnelUser           string `json:"tunnel_user"`
	AdditionalProperties any    `additionalProperties:"true" json:"-"`
}

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

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

func (o *SourceSapHanaEnterpriseSSHKeyAuthentication) GetSSHKey() string {
	if o == nil {
		return ""
	}
	return o.SSHKey
}

func (o *SourceSapHanaEnterpriseSSHKeyAuthentication) GetTunnelHost() string {
	if o == nil {
		return ""
	}
	return o.TunnelHost
}

func (o *SourceSapHanaEnterpriseSSHKeyAuthentication) GetTunnelMethod() *SourceSapHanaEnterpriseSchemasTunnelMethod {
	if o == nil {
		return nil
	}
	return o.TunnelMethod
}

func (o *SourceSapHanaEnterpriseSSHKeyAuthentication) GetTunnelPort() *int64 {
	if o == nil {
		return nil
	}
	return o.TunnelPort
}

func (o *SourceSapHanaEnterpriseSSHKeyAuthentication) GetTunnelUser() string {
	if o == nil {
		return ""
	}
	return o.TunnelUser
}

func (o *SourceSapHanaEnterpriseSSHKeyAuthentication) GetAdditionalProperties() any {
	if o == nil {
		return nil
	}
	return o.AdditionalProperties
}

type SourceSapHanaEnterpriseTunnelMethod string

const (
	SourceSapHanaEnterpriseTunnelMethodNoTunnel SourceSapHanaEnterpriseTunnelMethod = "NO_TUNNEL"
)

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

// SourceSapHanaEnterpriseNoTunnel - No ssh tunnel needed to connect to database
type SourceSapHanaEnterpriseNoTunnel struct {
	TunnelMethod         *SourceSapHanaEnterpriseTunnelMethod `default:"NO_TUNNEL" json:"tunnel_method"`
	AdditionalProperties any                                  `additionalProperties:"true" json:"-"`
}

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

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

func (o *SourceSapHanaEnterpriseNoTunnel) GetTunnelMethod() *SourceSapHanaEnterpriseTunnelMethod {
	if o == nil {
		return nil
	}
	return o.TunnelMethod
}

func (o *SourceSapHanaEnterpriseNoTunnel) GetAdditionalProperties() any {
	if o == nil {
		return nil
	}
	return o.AdditionalProperties
}

type SourceSapHanaEnterpriseSSHTunnelMethodType string

const (
	SourceSapHanaEnterpriseSSHTunnelMethodTypeSourceSapHanaEnterpriseNoTunnel               SourceSapHanaEnterpriseSSHTunnelMethodType = "source-sap-hana-enterprise_No Tunnel"
	SourceSapHanaEnterpriseSSHTunnelMethodTypeSourceSapHanaEnterpriseSSHKeyAuthentication   SourceSapHanaEnterpriseSSHTunnelMethodType = "source-sap-hana-enterprise_SSH Key Authentication"
	SourceSapHanaEnterpriseSSHTunnelMethodTypeSourceSapHanaEnterprisePasswordAuthentication SourceSapHanaEnterpriseSSHTunnelMethodType = "source-sap-hana-enterprise_Password Authentication"
)

// SourceSapHanaEnterpriseSSHTunnelMethod - Whether to initiate an SSH tunnel before connecting to the database, and if so, which kind of authentication to use.
type SourceSapHanaEnterpriseSSHTunnelMethod struct {
	SourceSapHanaEnterpriseNoTunnel               *SourceSapHanaEnterpriseNoTunnel               `queryParam:"inline"`
	SourceSapHanaEnterpriseSSHKeyAuthentication   *SourceSapHanaEnterpriseSSHKeyAuthentication   `queryParam:"inline"`
	SourceSapHanaEnterprisePasswordAuthentication *SourceSapHanaEnterprisePasswordAuthentication `queryParam:"inline"`

	Type SourceSapHanaEnterpriseSSHTunnelMethodType
}

func CreateSourceSapHanaEnterpriseSSHTunnelMethodSourceSapHanaEnterpriseNoTunnel(sourceSapHanaEnterpriseNoTunnel SourceSapHanaEnterpriseNoTunnel) SourceSapHanaEnterpriseSSHTunnelMethod {
	typ := SourceSapHanaEnterpriseSSHTunnelMethodTypeSourceSapHanaEnterpriseNoTunnel

	return SourceSapHanaEnterpriseSSHTunnelMethod{
		SourceSapHanaEnterpriseNoTunnel: &sourceSapHanaEnterpriseNoTunnel,
		Type:                            typ,
	}
}

func CreateSourceSapHanaEnterpriseSSHTunnelMethodSourceSapHanaEnterpriseSSHKeyAuthentication(sourceSapHanaEnterpriseSSHKeyAuthentication SourceSapHanaEnterpriseSSHKeyAuthentication) SourceSapHanaEnterpriseSSHTunnelMethod {
	typ := SourceSapHanaEnterpriseSSHTunnelMethodTypeSourceSapHanaEnterpriseSSHKeyAuthentication

	return SourceSapHanaEnterpriseSSHTunnelMethod{
		SourceSapHanaEnterpriseSSHKeyAuthentication: &sourceSapHanaEnterpriseSSHKeyAuthentication,
		Type: typ,
	}
}

func CreateSourceSapHanaEnterpriseSSHTunnelMethodSourceSapHanaEnterprisePasswordAuthentication(sourceSapHanaEnterprisePasswordAuthentication SourceSapHanaEnterprisePasswordAuthentication) SourceSapHanaEnterpriseSSHTunnelMethod {
	typ := SourceSapHanaEnterpriseSSHTunnelMethodTypeSourceSapHanaEnterprisePasswordAuthentication

	return SourceSapHanaEnterpriseSSHTunnelMethod{
		SourceSapHanaEnterprisePasswordAuthentication: &sourceSapHanaEnterprisePasswordAuthentication,
		Type: typ,
	}
}

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

	var sourceSapHanaEnterpriseNoTunnel SourceSapHanaEnterpriseNoTunnel = SourceSapHanaEnterpriseNoTunnel{}
	if err := utils.UnmarshalJSON(data, &sourceSapHanaEnterpriseNoTunnel, "", true, true); err == nil {
		u.SourceSapHanaEnterpriseNoTunnel = &sourceSapHanaEnterpriseNoTunnel
		u.Type = SourceSapHanaEnterpriseSSHTunnelMethodTypeSourceSapHanaEnterpriseNoTunnel
		return nil
	}

	var sourceSapHanaEnterpriseSSHKeyAuthentication SourceSapHanaEnterpriseSSHKeyAuthentication = SourceSapHanaEnterpriseSSHKeyAuthentication{}
	if err := utils.UnmarshalJSON(data, &sourceSapHanaEnterpriseSSHKeyAuthentication, "", true, true); err == nil {
		u.SourceSapHanaEnterpriseSSHKeyAuthentication = &sourceSapHanaEnterpriseSSHKeyAuthentication
		u.Type = SourceSapHanaEnterpriseSSHTunnelMethodTypeSourceSapHanaEnterpriseSSHKeyAuthentication
		return nil
	}

	var sourceSapHanaEnterprisePasswordAuthentication SourceSapHanaEnterprisePasswordAuthentication = SourceSapHanaEnterprisePasswordAuthentication{}
	if err := utils.UnmarshalJSON(data, &sourceSapHanaEnterprisePasswordAuthentication, "", true, true); err == nil {
		u.SourceSapHanaEnterprisePasswordAuthentication = &sourceSapHanaEnterprisePasswordAuthentication
		u.Type = SourceSapHanaEnterpriseSSHTunnelMethodTypeSourceSapHanaEnterprisePasswordAuthentication
		return nil
	}

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

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

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

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

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

type SapHanaEnterprise string

const (
	SapHanaEnterpriseSapHanaEnterprise SapHanaEnterprise = "sap-hana-enterprise"
)

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

type SourceSapHanaEnterprise struct {
	// When this feature is enabled, during schema discovery the connector will query each table or view individually to check access privileges and inaccessible tables, views, or columns therein will be removed. In large schemas, this might cause schema discovery to take too long, in which case it might be advisable to disable this feature.
	CheckPrivileges *bool `default:"true" json:"check_privileges"`
	// How often (in seconds) a stream should checkpoint, when possible.
	CheckpointTargetIntervalSeconds *int64 `default:"300" json:"checkpoint_target_interval_seconds"`
	// Maximum number of concurrent queries to the database.
	Concurrency *int64 `default:"1" json:"concurrency"`
	// Configures how data is extracted from the database.
	Cursor SourceSapHanaEnterpriseUpdateMethod `json:"cursor"`
	// The encryption method with is used when communicating with the database.
	Encryption SourceSapHanaEnterpriseEncryption `json:"encryption"`
	// Hostname of the database.
	Host string `json:"host"`
	// Additional properties to pass to the JDBC URL string when connecting to the database formatted as 'key=value' pairs separated by the symbol '&'. (example: key1=value1&key2=value2&key3=value3).
	JdbcURLParams *string `json:"jdbc_url_params,omitempty"`
	// The password associated with the username.
	Password *string `json:"password,omitempty"`
	// Port of the database.
	// SapHana Corporations recommends the following port numbers:
	// 443 - Default listening port for SAP HANA cloud client connections to the listener.
	Port *int64 `default:"443" json:"port"`
	// The list of schemas to sync from. Defaults to user. Case sensitive.
	Schemas []string `json:"schemas,omitempty"`
	// Whether to initiate an SSH tunnel before connecting to the database, and if so, which kind of authentication to use.
	TunnelMethod SourceSapHanaEnterpriseSSHTunnelMethod `json:"tunnel_method"`
	// The username which is used to access the database.
	Username   string            `json:"username"`
	sourceType SapHanaEnterprise `const:"sap-hana-enterprise" json:"sourceType"`
}

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

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

func (o *SourceSapHanaEnterprise) GetCheckPrivileges() *bool {
	if o == nil {
		return nil
	}
	return o.CheckPrivileges
}

func (o *SourceSapHanaEnterprise) GetCheckpointTargetIntervalSeconds() *int64 {
	if o == nil {
		return nil
	}
	return o.CheckpointTargetIntervalSeconds
}

func (o *SourceSapHanaEnterprise) GetConcurrency() *int64 {
	if o == nil {
		return nil
	}
	return o.Concurrency
}

func (o *SourceSapHanaEnterprise) GetCursor() SourceSapHanaEnterpriseUpdateMethod {
	if o == nil {
		return SourceSapHanaEnterpriseUpdateMethod{}
	}
	return o.Cursor
}

func (o *SourceSapHanaEnterprise) GetEncryption() SourceSapHanaEnterpriseEncryption {
	if o == nil {
		return SourceSapHanaEnterpriseEncryption{}
	}
	return o.Encryption
}

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

func (o *SourceSapHanaEnterprise) GetJdbcURLParams() *string {
	if o == nil {
		return nil
	}
	return o.JdbcURLParams
}

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

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

func (o *SourceSapHanaEnterprise) GetSchemas() []string {
	if o == nil {
		return nil
	}
	return o.Schemas
}

func (o *SourceSapHanaEnterprise) GetTunnelMethod() SourceSapHanaEnterpriseSSHTunnelMethod {
	if o == nil {
		return SourceSapHanaEnterpriseSSHTunnelMethod{}
	}
	return o.TunnelMethod
}

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

func (o *SourceSapHanaEnterprise) GetSourceType() SapHanaEnterprise {
	return SapHanaEnterpriseSapHanaEnterprise
}
