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

const (
	DockerhubDockerhub Dockerhub = "dockerhub"
)

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

type SourceDockerhub struct {
	// Username of DockerHub person or organization (for https://hub.docker.com/v2/repositories/USERNAME/ API call)
	DockerUsername string    `json:"docker_username"`
	sourceType     Dockerhub `const:"dockerhub" json:"sourceType"`
}

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

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

func (o *SourceDockerhub) GetDockerUsername() string {
	if o == nil {
		return ""
	}
	return o.DockerUsername
}

func (o *SourceDockerhub) GetSourceType() Dockerhub {
	return DockerhubDockerhub
}
