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

const (
	SourceModeModeMode SourceModeMode = "mode"
)

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

type SourceMode struct {
	// API secret to use as the password for Basic Authentication.
	APISecret string `json:"api_secret"`
	// API token to use as the username for Basic Authentication.
	APIToken   string         `json:"api_token"`
	Workspace  string         `json:"workspace"`
	sourceType SourceModeMode `const:"mode" json:"sourceType"`
}

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

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

func (o *SourceMode) GetAPISecret() string {
	if o == nil {
		return ""
	}
	return o.APISecret
}

func (o *SourceMode) GetAPIToken() string {
	if o == nil {
		return ""
	}
	return o.APIToken
}

func (o *SourceMode) GetWorkspace() string {
	if o == nil {
		return ""
	}
	return o.Workspace
}

func (o *SourceMode) GetSourceType() SourceModeMode {
	return SourceModeModeMode
}
