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

const (
	UnleashUnleash Unleash = "unleash"
)

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

type SourceUnleash struct {
	// Your API Token (Server-Side SDK [Client]). See <a href="https://docs.getunleash.io/how-to/how-to-create-api-tokens/">here</a>. The token is case sensitive.
	APIToken string `json:"api_token"`
	// Your API URL. No trailing slash. ex: https://unleash.host.com/api
	APIURL string `json:"api_url"`
	// Use this if you want to filter the API call for only one given project (can be used in addition to the "Feature Name Prefix" field). See <a href="https://docs.getunleash.io/reference/api/legacy/unleash/client/features#filter-feature-toggles">here</a>
	Nameprefix *string `json:"nameprefix,omitempty"`
	// Use this if you want to filter the API call for only one given project (can be used in addition to the "Feature Name Prefix" field). See <a href="https://docs.getunleash.io/reference/api/legacy/unleash/client/features#filter-feature-toggles">here</a>
	ProjectName *string `json:"project_name,omitempty"`
	sourceType  Unleash `const:"unleash" json:"sourceType"`
}

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

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

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

func (o *SourceUnleash) GetAPIURL() string {
	if o == nil {
		return ""
	}
	return o.APIURL
}

func (o *SourceUnleash) GetNameprefix() *string {
	if o == nil {
		return nil
	}
	return o.Nameprefix
}

func (o *SourceUnleash) GetProjectName() *string {
	if o == nil {
		return nil
	}
	return o.ProjectName
}

func (o *SourceUnleash) GetSourceType() Unleash {
	return UnleashUnleash
}
