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

const (
	DestinationYellowbrickSchemasSSLModeSSLModes6ModeVerifyFull DestinationYellowbrickSchemasSSLModeSSLModes6Mode = "verify-full"
)

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

// DestinationYellowbrickVerifyFull - Verify-full SSL mode.
type DestinationYellowbrickVerifyFull struct {
	// CA certificate
	CaCertificate string `json:"ca_certificate"`
	// Client certificate
	ClientCertificate string `json:"client_certificate"`
	// Client key
	ClientKey string `json:"client_key"`
	// Password for keystorage. This field is optional. If you do not add it - the password will be generated automatically.
	ClientKeyPassword *string                                            `json:"client_key_password,omitempty"`
	mode              *DestinationYellowbrickSchemasSSLModeSSLModes6Mode `const:"verify-full" json:"mode"`
}

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

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

func (o *DestinationYellowbrickVerifyFull) GetCaCertificate() string {
	if o == nil {
		return ""
	}
	return o.CaCertificate
}

func (o *DestinationYellowbrickVerifyFull) GetClientCertificate() string {
	if o == nil {
		return ""
	}
	return o.ClientCertificate
}

func (o *DestinationYellowbrickVerifyFull) GetClientKey() string {
	if o == nil {
		return ""
	}
	return o.ClientKey
}

func (o *DestinationYellowbrickVerifyFull) GetClientKeyPassword() *string {
	if o == nil {
		return nil
	}
	return o.ClientKeyPassword
}

func (o *DestinationYellowbrickVerifyFull) GetMode() *DestinationYellowbrickSchemasSSLModeSSLModes6Mode {
	return DestinationYellowbrickSchemasSSLModeSSLModes6ModeVerifyFull.ToPointer()
}

type DestinationYellowbrickSchemasSSLModeSSLModes5Mode string

const (
	DestinationYellowbrickSchemasSSLModeSSLModes5ModeVerifyCa DestinationYellowbrickSchemasSSLModeSSLModes5Mode = "verify-ca"
)

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

// DestinationYellowbrickVerifyCa - Verify-ca SSL mode.
type DestinationYellowbrickVerifyCa struct {
	// CA certificate
	CaCertificate string `json:"ca_certificate"`
	// Password for keystorage. This field is optional. If you do not add it - the password will be generated automatically.
	ClientKeyPassword *string                                            `json:"client_key_password,omitempty"`
	mode              *DestinationYellowbrickSchemasSSLModeSSLModes5Mode `const:"verify-ca" json:"mode"`
}

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

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

func (o *DestinationYellowbrickVerifyCa) GetCaCertificate() string {
	if o == nil {
		return ""
	}
	return o.CaCertificate
}

func (o *DestinationYellowbrickVerifyCa) GetClientKeyPassword() *string {
	if o == nil {
		return nil
	}
	return o.ClientKeyPassword
}

func (o *DestinationYellowbrickVerifyCa) GetMode() *DestinationYellowbrickSchemasSSLModeSSLModes5Mode {
	return DestinationYellowbrickSchemasSSLModeSSLModes5ModeVerifyCa.ToPointer()
}

type DestinationYellowbrickSchemasSSLModeSSLModesMode string

const (
	DestinationYellowbrickSchemasSSLModeSSLModesModeRequire DestinationYellowbrickSchemasSSLModeSSLModesMode = "require"
)

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

// DestinationYellowbrickRequire - Require SSL mode.
type DestinationYellowbrickRequire struct {
	mode *DestinationYellowbrickSchemasSSLModeSSLModesMode `const:"require" json:"mode"`
}

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

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

func (o *DestinationYellowbrickRequire) GetMode() *DestinationYellowbrickSchemasSSLModeSSLModesMode {
	return DestinationYellowbrickSchemasSSLModeSSLModesModeRequire.ToPointer()
}

type DestinationYellowbrickSchemasSslModeMode string

const (
	DestinationYellowbrickSchemasSslModeModePrefer DestinationYellowbrickSchemasSslModeMode = "prefer"
)

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

// DestinationYellowbrickPrefer - Prefer SSL mode.
type DestinationYellowbrickPrefer struct {
	mode *DestinationYellowbrickSchemasSslModeMode `const:"prefer" json:"mode"`
}

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

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

func (o *DestinationYellowbrickPrefer) GetMode() *DestinationYellowbrickSchemasSslModeMode {
	return DestinationYellowbrickSchemasSslModeModePrefer.ToPointer()
}

type DestinationYellowbrickSchemasMode string

const (
	DestinationYellowbrickSchemasModeAllow DestinationYellowbrickSchemasMode = "allow"
)

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

// DestinationYellowbrickAllow - Allow SSL mode.
type DestinationYellowbrickAllow struct {
	mode *DestinationYellowbrickSchemasMode `const:"allow" json:"mode"`
}

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

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

func (o *DestinationYellowbrickAllow) GetMode() *DestinationYellowbrickSchemasMode {
	return DestinationYellowbrickSchemasModeAllow.ToPointer()
}

type DestinationYellowbrickMode string

const (
	DestinationYellowbrickModeDisable DestinationYellowbrickMode = "disable"
)

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

// DestinationYellowbrickDisable - Disable SSL.
type DestinationYellowbrickDisable struct {
	mode *DestinationYellowbrickMode `const:"disable" json:"mode"`
}

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

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

func (o *DestinationYellowbrickDisable) GetMode() *DestinationYellowbrickMode {
	return DestinationYellowbrickModeDisable.ToPointer()
}

type DestinationYellowbrickSSLModesType string

const (
	DestinationYellowbrickSSLModesTypeDestinationYellowbrickDisable    DestinationYellowbrickSSLModesType = "destination-yellowbrick_disable"
	DestinationYellowbrickSSLModesTypeDestinationYellowbrickAllow      DestinationYellowbrickSSLModesType = "destination-yellowbrick_allow"
	DestinationYellowbrickSSLModesTypeDestinationYellowbrickPrefer     DestinationYellowbrickSSLModesType = "destination-yellowbrick_prefer"
	DestinationYellowbrickSSLModesTypeDestinationYellowbrickRequire    DestinationYellowbrickSSLModesType = "destination-yellowbrick_require"
	DestinationYellowbrickSSLModesTypeDestinationYellowbrickVerifyCa   DestinationYellowbrickSSLModesType = "destination-yellowbrick_verify-ca"
	DestinationYellowbrickSSLModesTypeDestinationYellowbrickVerifyFull DestinationYellowbrickSSLModesType = "destination-yellowbrick_verify-full"
)

// DestinationYellowbrickSSLModes - SSL connection modes.
//
//	<b>disable</b> - Chose this mode to disable encryption of communication between Airbyte and destination database
//	<b>allow</b> - Chose this mode to enable encryption only when required by the source database
//	<b>prefer</b> - Chose this mode to allow unencrypted connection only if the source database does not support encryption
//	<b>require</b> - Chose this mode to always require encryption. If the source database server does not support encryption, connection will fail
//	 <b>verify-ca</b> - Chose this mode to always require encryption and to verify that the source database server has a valid SSL certificate
//	 <b>verify-full</b> - This is the most secure mode. Chose this mode to always require encryption and to verify the identity of the source database server
//	See more information - <a href="https://jdbc.postgresql.org/documentation/head/ssl-client.html"> in the docs</a>.
type DestinationYellowbrickSSLModes struct {
	DestinationYellowbrickDisable    *DestinationYellowbrickDisable    `queryParam:"inline"`
	DestinationYellowbrickAllow      *DestinationYellowbrickAllow      `queryParam:"inline"`
	DestinationYellowbrickPrefer     *DestinationYellowbrickPrefer     `queryParam:"inline"`
	DestinationYellowbrickRequire    *DestinationYellowbrickRequire    `queryParam:"inline"`
	DestinationYellowbrickVerifyCa   *DestinationYellowbrickVerifyCa   `queryParam:"inline"`
	DestinationYellowbrickVerifyFull *DestinationYellowbrickVerifyFull `queryParam:"inline"`

	Type DestinationYellowbrickSSLModesType
}

func CreateDestinationYellowbrickSSLModesDestinationYellowbrickDisable(destinationYellowbrickDisable DestinationYellowbrickDisable) DestinationYellowbrickSSLModes {
	typ := DestinationYellowbrickSSLModesTypeDestinationYellowbrickDisable

	return DestinationYellowbrickSSLModes{
		DestinationYellowbrickDisable: &destinationYellowbrickDisable,
		Type:                          typ,
	}
}

func CreateDestinationYellowbrickSSLModesDestinationYellowbrickAllow(destinationYellowbrickAllow DestinationYellowbrickAllow) DestinationYellowbrickSSLModes {
	typ := DestinationYellowbrickSSLModesTypeDestinationYellowbrickAllow

	return DestinationYellowbrickSSLModes{
		DestinationYellowbrickAllow: &destinationYellowbrickAllow,
		Type:                        typ,
	}
}

func CreateDestinationYellowbrickSSLModesDestinationYellowbrickPrefer(destinationYellowbrickPrefer DestinationYellowbrickPrefer) DestinationYellowbrickSSLModes {
	typ := DestinationYellowbrickSSLModesTypeDestinationYellowbrickPrefer

	return DestinationYellowbrickSSLModes{
		DestinationYellowbrickPrefer: &destinationYellowbrickPrefer,
		Type:                         typ,
	}
}

func CreateDestinationYellowbrickSSLModesDestinationYellowbrickRequire(destinationYellowbrickRequire DestinationYellowbrickRequire) DestinationYellowbrickSSLModes {
	typ := DestinationYellowbrickSSLModesTypeDestinationYellowbrickRequire

	return DestinationYellowbrickSSLModes{
		DestinationYellowbrickRequire: &destinationYellowbrickRequire,
		Type:                          typ,
	}
}

func CreateDestinationYellowbrickSSLModesDestinationYellowbrickVerifyCa(destinationYellowbrickVerifyCa DestinationYellowbrickVerifyCa) DestinationYellowbrickSSLModes {
	typ := DestinationYellowbrickSSLModesTypeDestinationYellowbrickVerifyCa

	return DestinationYellowbrickSSLModes{
		DestinationYellowbrickVerifyCa: &destinationYellowbrickVerifyCa,
		Type:                           typ,
	}
}

func CreateDestinationYellowbrickSSLModesDestinationYellowbrickVerifyFull(destinationYellowbrickVerifyFull DestinationYellowbrickVerifyFull) DestinationYellowbrickSSLModes {
	typ := DestinationYellowbrickSSLModesTypeDestinationYellowbrickVerifyFull

	return DestinationYellowbrickSSLModes{
		DestinationYellowbrickVerifyFull: &destinationYellowbrickVerifyFull,
		Type:                             typ,
	}
}

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

	var destinationYellowbrickDisable DestinationYellowbrickDisable = DestinationYellowbrickDisable{}
	if err := utils.UnmarshalJSON(data, &destinationYellowbrickDisable, "", true, true); err == nil {
		u.DestinationYellowbrickDisable = &destinationYellowbrickDisable
		u.Type = DestinationYellowbrickSSLModesTypeDestinationYellowbrickDisable
		return nil
	}

	var destinationYellowbrickAllow DestinationYellowbrickAllow = DestinationYellowbrickAllow{}
	if err := utils.UnmarshalJSON(data, &destinationYellowbrickAllow, "", true, true); err == nil {
		u.DestinationYellowbrickAllow = &destinationYellowbrickAllow
		u.Type = DestinationYellowbrickSSLModesTypeDestinationYellowbrickAllow
		return nil
	}

	var destinationYellowbrickPrefer DestinationYellowbrickPrefer = DestinationYellowbrickPrefer{}
	if err := utils.UnmarshalJSON(data, &destinationYellowbrickPrefer, "", true, true); err == nil {
		u.DestinationYellowbrickPrefer = &destinationYellowbrickPrefer
		u.Type = DestinationYellowbrickSSLModesTypeDestinationYellowbrickPrefer
		return nil
	}

	var destinationYellowbrickRequire DestinationYellowbrickRequire = DestinationYellowbrickRequire{}
	if err := utils.UnmarshalJSON(data, &destinationYellowbrickRequire, "", true, true); err == nil {
		u.DestinationYellowbrickRequire = &destinationYellowbrickRequire
		u.Type = DestinationYellowbrickSSLModesTypeDestinationYellowbrickRequire
		return nil
	}

	var destinationYellowbrickVerifyCa DestinationYellowbrickVerifyCa = DestinationYellowbrickVerifyCa{}
	if err := utils.UnmarshalJSON(data, &destinationYellowbrickVerifyCa, "", true, true); err == nil {
		u.DestinationYellowbrickVerifyCa = &destinationYellowbrickVerifyCa
		u.Type = DestinationYellowbrickSSLModesTypeDestinationYellowbrickVerifyCa
		return nil
	}

	var destinationYellowbrickVerifyFull DestinationYellowbrickVerifyFull = DestinationYellowbrickVerifyFull{}
	if err := utils.UnmarshalJSON(data, &destinationYellowbrickVerifyFull, "", true, true); err == nil {
		u.DestinationYellowbrickVerifyFull = &destinationYellowbrickVerifyFull
		u.Type = DestinationYellowbrickSSLModesTypeDestinationYellowbrickVerifyFull
		return nil
	}

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

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

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

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

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

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

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

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

// DestinationYellowbrickSchemasTunnelMethodTunnelMethod - Connect through a jump server tunnel host using username and password authentication
type DestinationYellowbrickSchemasTunnelMethodTunnelMethod string

const (
	DestinationYellowbrickSchemasTunnelMethodTunnelMethodSSHPasswordAuth DestinationYellowbrickSchemasTunnelMethodTunnelMethod = "SSH_PASSWORD_AUTH"
)

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

type DestinationYellowbrickPasswordAuthentication struct {
	// Hostname of the jump server host that allows inbound ssh tunnel.
	TunnelHost string `json:"tunnel_host"`
	// Connect through a jump server tunnel host using username and password authentication
	tunnelMethod DestinationYellowbrickSchemasTunnelMethodTunnelMethod `const:"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"`
}

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

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

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

func (o *DestinationYellowbrickPasswordAuthentication) GetTunnelMethod() DestinationYellowbrickSchemasTunnelMethodTunnelMethod {
	return DestinationYellowbrickSchemasTunnelMethodTunnelMethodSSHPasswordAuth
}

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

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

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

// DestinationYellowbrickSchemasTunnelMethod - Connect through a jump server tunnel host using username and ssh key
type DestinationYellowbrickSchemasTunnelMethod string

const (
	DestinationYellowbrickSchemasTunnelMethodSSHKeyAuth DestinationYellowbrickSchemasTunnelMethod = "SSH_KEY_AUTH"
)

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

type DestinationYellowbrickSSHKeyAuthentication 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"`
	// Connect through a jump server tunnel host using username and ssh key
	tunnelMethod DestinationYellowbrickSchemasTunnelMethod `const:"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"`
}

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

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

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

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

func (o *DestinationYellowbrickSSHKeyAuthentication) GetTunnelMethod() DestinationYellowbrickSchemasTunnelMethod {
	return DestinationYellowbrickSchemasTunnelMethodSSHKeyAuth
}

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

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

// DestinationYellowbrickTunnelMethod - No ssh tunnel needed to connect to database
type DestinationYellowbrickTunnelMethod string

const (
	DestinationYellowbrickTunnelMethodNoTunnel DestinationYellowbrickTunnelMethod = "NO_TUNNEL"
)

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

type DestinationYellowbrickNoTunnel struct {
	// No ssh tunnel needed to connect to database
	tunnelMethod DestinationYellowbrickTunnelMethod `const:"NO_TUNNEL" json:"tunnel_method"`
}

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

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

func (o *DestinationYellowbrickNoTunnel) GetTunnelMethod() DestinationYellowbrickTunnelMethod {
	return DestinationYellowbrickTunnelMethodNoTunnel
}

type DestinationYellowbrickSSHTunnelMethodType string

const (
	DestinationYellowbrickSSHTunnelMethodTypeDestinationYellowbrickNoTunnel               DestinationYellowbrickSSHTunnelMethodType = "destination-yellowbrick_No Tunnel"
	DestinationYellowbrickSSHTunnelMethodTypeDestinationYellowbrickSSHKeyAuthentication   DestinationYellowbrickSSHTunnelMethodType = "destination-yellowbrick_SSH Key Authentication"
	DestinationYellowbrickSSHTunnelMethodTypeDestinationYellowbrickPasswordAuthentication DestinationYellowbrickSSHTunnelMethodType = "destination-yellowbrick_Password Authentication"
)

// DestinationYellowbrickSSHTunnelMethod - Whether to initiate an SSH tunnel before connecting to the database, and if so, which kind of authentication to use.
type DestinationYellowbrickSSHTunnelMethod struct {
	DestinationYellowbrickNoTunnel               *DestinationYellowbrickNoTunnel               `queryParam:"inline"`
	DestinationYellowbrickSSHKeyAuthentication   *DestinationYellowbrickSSHKeyAuthentication   `queryParam:"inline"`
	DestinationYellowbrickPasswordAuthentication *DestinationYellowbrickPasswordAuthentication `queryParam:"inline"`

	Type DestinationYellowbrickSSHTunnelMethodType
}

func CreateDestinationYellowbrickSSHTunnelMethodDestinationYellowbrickNoTunnel(destinationYellowbrickNoTunnel DestinationYellowbrickNoTunnel) DestinationYellowbrickSSHTunnelMethod {
	typ := DestinationYellowbrickSSHTunnelMethodTypeDestinationYellowbrickNoTunnel

	return DestinationYellowbrickSSHTunnelMethod{
		DestinationYellowbrickNoTunnel: &destinationYellowbrickNoTunnel,
		Type:                           typ,
	}
}

func CreateDestinationYellowbrickSSHTunnelMethodDestinationYellowbrickSSHKeyAuthentication(destinationYellowbrickSSHKeyAuthentication DestinationYellowbrickSSHKeyAuthentication) DestinationYellowbrickSSHTunnelMethod {
	typ := DestinationYellowbrickSSHTunnelMethodTypeDestinationYellowbrickSSHKeyAuthentication

	return DestinationYellowbrickSSHTunnelMethod{
		DestinationYellowbrickSSHKeyAuthentication: &destinationYellowbrickSSHKeyAuthentication,
		Type: typ,
	}
}

func CreateDestinationYellowbrickSSHTunnelMethodDestinationYellowbrickPasswordAuthentication(destinationYellowbrickPasswordAuthentication DestinationYellowbrickPasswordAuthentication) DestinationYellowbrickSSHTunnelMethod {
	typ := DestinationYellowbrickSSHTunnelMethodTypeDestinationYellowbrickPasswordAuthentication

	return DestinationYellowbrickSSHTunnelMethod{
		DestinationYellowbrickPasswordAuthentication: &destinationYellowbrickPasswordAuthentication,
		Type: typ,
	}
}

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

	var destinationYellowbrickNoTunnel DestinationYellowbrickNoTunnel = DestinationYellowbrickNoTunnel{}
	if err := utils.UnmarshalJSON(data, &destinationYellowbrickNoTunnel, "", true, true); err == nil {
		u.DestinationYellowbrickNoTunnel = &destinationYellowbrickNoTunnel
		u.Type = DestinationYellowbrickSSHTunnelMethodTypeDestinationYellowbrickNoTunnel
		return nil
	}

	var destinationYellowbrickSSHKeyAuthentication DestinationYellowbrickSSHKeyAuthentication = DestinationYellowbrickSSHKeyAuthentication{}
	if err := utils.UnmarshalJSON(data, &destinationYellowbrickSSHKeyAuthentication, "", true, true); err == nil {
		u.DestinationYellowbrickSSHKeyAuthentication = &destinationYellowbrickSSHKeyAuthentication
		u.Type = DestinationYellowbrickSSHTunnelMethodTypeDestinationYellowbrickSSHKeyAuthentication
		return nil
	}

	var destinationYellowbrickPasswordAuthentication DestinationYellowbrickPasswordAuthentication = DestinationYellowbrickPasswordAuthentication{}
	if err := utils.UnmarshalJSON(data, &destinationYellowbrickPasswordAuthentication, "", true, true); err == nil {
		u.DestinationYellowbrickPasswordAuthentication = &destinationYellowbrickPasswordAuthentication
		u.Type = DestinationYellowbrickSSHTunnelMethodTypeDestinationYellowbrickPasswordAuthentication
		return nil
	}

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

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

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

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

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

type Yellowbrick string

const (
	YellowbrickYellowbrick Yellowbrick = "yellowbrick"
)

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

type DestinationYellowbrick struct {
	// Name of the database.
	Database string `json:"database"`
	// 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"`
	// Password associated with the username.
	Password *string `json:"password,omitempty"`
	// Port of the database.
	Port *int64 `default:"5432" json:"port"`
	// The default schema tables are written to if the source does not specify a namespace. The usual value for this field is "public".
	Schema *string `default:"public" json:"schema"`
	// Encrypt data using SSL. When activating SSL, please select one of the connection modes.
	Ssl *bool `default:"false" json:"ssl"`
	// SSL connection modes.
	//  <b>disable</b> - Chose this mode to disable encryption of communication between Airbyte and destination database
	//  <b>allow</b> - Chose this mode to enable encryption only when required by the source database
	//  <b>prefer</b> - Chose this mode to allow unencrypted connection only if the source database does not support encryption
	//  <b>require</b> - Chose this mode to always require encryption. If the source database server does not support encryption, connection will fail
	//   <b>verify-ca</b> - Chose this mode to always require encryption and to verify that the source database server has a valid SSL certificate
	//   <b>verify-full</b> - This is the most secure mode. Chose this mode to always require encryption and to verify the identity of the source database server
	//  See more information - <a href="https://jdbc.postgresql.org/documentation/head/ssl-client.html"> in the docs</a>.
	SslMode *DestinationYellowbrickSSLModes `json:"ssl_mode,omitempty"`
	// Whether to initiate an SSH tunnel before connecting to the database, and if so, which kind of authentication to use.
	TunnelMethod *DestinationYellowbrickSSHTunnelMethod `json:"tunnel_method,omitempty"`
	// Username to use to access the database.
	Username        string      `json:"username"`
	destinationType Yellowbrick `const:"yellowbrick" json:"destinationType"`
}

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

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

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

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

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

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

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

func (o *DestinationYellowbrick) GetSchema() *string {
	if o == nil {
		return nil
	}
	return o.Schema
}

func (o *DestinationYellowbrick) GetSsl() *bool {
	if o == nil {
		return nil
	}
	return o.Ssl
}

func (o *DestinationYellowbrick) GetSslMode() *DestinationYellowbrickSSLModes {
	if o == nil {
		return nil
	}
	return o.SslMode
}

func (o *DestinationYellowbrick) GetTunnelMethod() *DestinationYellowbrickSSHTunnelMethod {
	if o == nil {
		return nil
	}
	return o.TunnelMethod
}

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

func (o *DestinationYellowbrick) GetDestinationType() Yellowbrick {
	return YellowbrickYellowbrick
}
