api

package
v0.1.32 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2024 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoDevices         = errors.New("api: no devices set")
	ErrDownloadDirNotSet = errors.New("api: download directory not set")
)

Functions

This section is empty.

Types

type API

type API struct {
	// contains filtered or unexported fields
}

func New

func New(deps Dependencies) *API

func (*API) DeviceBySlug

func (api *API) DeviceBySlug(ctx context.Context, slug string) (device *models.Device, err error)

func (*API) DevicesCountEnabled

func (api *API) DevicesCountEnabled(ctx context.Context) (int64, error)

func (*API) DevicesCreate

func (api *API) DevicesCreate(ctx context.Context, params *models.Device) (device *models.Device, err error)

func (*API) DevicesExist

func (api *API) DevicesExist(ctx context.Context, slug string) (exist bool, err error)

func (*API) DevicesList

func (api *API) DevicesList(ctx context.Context, params DevicesListParams) (result DevicesListResult, err error)

func (*API) DevicesUpdate

func (api *API) DevicesUpdate(ctx context.Context, slug string, update *models.DeviceSetter) (device *models.Device, err error)

func (*API) DevicesValidateSlug

func (api *API) DevicesValidateSlug(ctx context.Context, slug string) (exist bool, err error)

func (*API) DownloadSubredditImages

func (api *API) DownloadSubredditImages(ctx context.Context, subreddit *models.Subreddit, devices models.DeviceSlice) error

func (*API) DownloadSubredditPosts

func (api *API) DownloadSubredditPosts(ctx context.Context, subredditName string, params DownloadSubredditPostsParams) (posts reddit.Listing, err error)

func (*API) GetDevices

func (api *API) GetDevices(ctx context.Context, params DevicesListParams) (result models.DeviceSlice, err error)

func (*API) GetEventBroadcaster

func (api *API) GetEventBroadcaster() *broadcast.Relay[events.Event]

func (*API) ImagesList

func (api *API) ImagesList(ctx context.Context, params ImageListParams) (result ImageListResult, err error)

func (*API) ImagesListWithDevicesAndSubreddits

func (api *API) ImagesListWithDevicesAndSubreddits(ctx context.Context, params ImageListParams) (result ImageListResult, err error)

func (*API) ListSubreddits

func (api *API) ListSubreddits(ctx context.Context, arg ListSubredditsParams) (result ListSubredditsResult, err error)

func (*API) ListSubredditsWithCover

func (api *API) ListSubredditsWithCover(ctx context.Context, arg ListSubredditsParams) (result ListSubredditsResult, err error)

ListSubredditsWithCover returns list of subreddits with cover image.

Image Relationship `R` struct will be nil if there is no cover image.

func (*API) PubsubStartDownloadSubreddit

func (api *API) PubsubStartDownloadSubreddit(ctx context.Context, params PubsubStartDownloadSubredditParams) (err error)

func (*API) ScheduleHistoryInsert

func (api *API) ScheduleHistoryInsert(ctx context.Context, params ScheduleSetParams) (history *models.ScheduleHistory, err error)

func (*API) ScheduleHistoryLatest

func (api *API) ScheduleHistoryLatest(ctx context.Context) (result *models.ScheduleHistory, err error)

func (*API) ScheduleHistoryList

func (api *API) ScheduleHistoryList(ctx context.Context, params ScheduleHistoryListParams) (result ScheduleHistoryListResult, err error)

func (*API) ScheduleHistoryListByDate

func (api *API) ScheduleHistoryListByDate(ctx context.Context, params ScheduleHistoryListByDateParams) (result ScheduleHistoryListResult, err error)

func (*API) ScheduleSet

func (api *API) ScheduleSet(ctx context.Context, params ScheduleSetParams) (schedule *models.ScheduleStatus, err error)

func (*API) ScheduleStatusUpsert

func (api *API) ScheduleStatusUpsert(ctx context.Context, params ScheduleSetParams) (schedule *models.ScheduleStatus, err error)

func (*API) StartSubredditDownloadPubsub

func (api *API) StartSubredditDownloadPubsub(messages <-chan *message.Message)

func (*API) SubredditCheck

func (api *API) SubredditCheck(ctx context.Context, params SubredditCheckParam) (actual string, err error)

func (*API) SubredditGetByNameWithImages

func (api *API) SubredditGetByNameWithImages(ctx context.Context, name string, imageParams SubredditGetByNameImageParams) (result SubredditGetByNameImageResult, err error)

func (*API) SubredditRegistered

func (api *API) SubredditRegistered(ctx context.Context, params SubredditCheckParam) (registered bool, err error)

func (*API) SubredditsCreate

func (api *API) SubredditsCreate(ctx context.Context, params *models.Subreddit) (subreddit *models.Subreddit, err error)

func (*API) SubredditsEdit

func (api *API) SubredditsEdit(ctx context.Context, params SubredditEditParams) (subreddit *models.Subreddit, err error)

func (*API) SubredditsGetByName

func (api *API) SubredditsGetByName(ctx context.Context, name string) (subreddit *models.Subreddit, err error)

func (*API) SubscribeImageDownloadEvent

func (api *API) SubscribeImageDownloadEvent() (<-chan bmessage.ImageDownloadMessage, func())

type Dependencies

type Dependencies struct {
	DB         *sql.DB
	Config     *config.Config
	Reddit     *reddit.Reddit
	Publisher  message.Publisher
	Subscriber message.Subscriber
}

type DeviceCreateParams

type DeviceCreateParams = models.DeviceSetter

type DevicesListParams

type DevicesListParams struct {
	Q      string
	Status int

	Limit   int64
	Offset  int64
	OrderBy string
	Sort    string
}

func (DevicesListParams) CountQuery

func (dlp DevicesListParams) CountQuery() (expr []bob.Mod[*dialect.SelectQuery])

func (*DevicesListParams) FillFromQuery

func (dlp *DevicesListParams) FillFromQuery(query Queryable)

func (DevicesListParams) Query

func (dlp DevicesListParams) Query() (expr []bob.Mod[*dialect.SelectQuery])

type DevicesListResult

type DevicesListResult struct {
	Devices models.DeviceSlice `json:"devices"`
	Total   int64              `json:"total"`
}

type DownloadSubredditParams

type DownloadSubredditParams struct {
	Countback     int
	Devices       models.DeviceSlice
	SubredditType reddit.SubredditType
}

type DownloadSubredditPostsParams

type DownloadSubredditPostsParams struct {
	Page  int
	Limit int
}

type ImageListParams

type ImageListParams struct {
	Q         string
	NSFW      int32
	OrderBy   string
	Sort      string
	Offset    int64
	Limit     int64
	Device    string
	Subreddit string
	CreatedAt time.Time
}

func (ImageListParams) CountQuery

func (ilp ImageListParams) CountQuery() (expr []bob.Mod[*dialect.SelectQuery])

func (*ImageListParams) FillFromQuery

func (ilp *ImageListParams) FillFromQuery(query Queryable)

func (ImageListParams) Query

func (ilp ImageListParams) Query() (expr []bob.Mod[*dialect.SelectQuery])

type ImageListResult

type ImageListResult struct {
	Total  int64
	Images models.ImageSlice
}

func (ImageListResult) MarshalJSON

func (im ImageListResult) MarshalJSON() ([]byte, error)

type ListSubredditsParams

type ListSubredditsParams struct {
	Q       string
	All     bool
	Limit   int64
	Offset  int64
	OrderBy string
	Sort    string
	NSFW    int
}

func (ListSubredditsParams) CountQuery

func (l ListSubredditsParams) CountQuery() (expr []bob.Mod[*dialect.SelectQuery])

func (*ListSubredditsParams) FillFromQuery

func (l *ListSubredditsParams) FillFromQuery(q Queryable)

func (ListSubredditsParams) ImageCoverQuery

func (l ListSubredditsParams) ImageCoverQuery(subname string) (expr []bob.Mod[*dialect.SelectQuery])

func (ListSubredditsParams) Query

func (l ListSubredditsParams) Query() (expr []bob.Mod[*dialect.SelectQuery])

type ListSubredditsResult

type ListSubredditsResult struct {
	Total int64
	Data  models.SubredditSlice
}

type PubsubStartDownloadSubredditParams

type PubsubStartDownloadSubredditParams struct {
	Subreddit string `json:"subreddit"`
}

type Queryable

type Queryable interface {
	Get(string) string
}

type ScheduleHistoryListByDateParams

type ScheduleHistoryListByDateParams struct {
	Date time.Time
}

func (*ScheduleHistoryListByDateParams) CountQuery

func (params *ScheduleHistoryListByDateParams) CountQuery() (expr []bob.Mod[*dialect.SelectQuery])

func (*ScheduleHistoryListByDateParams) FillFromQuery

func (params *ScheduleHistoryListByDateParams) FillFromQuery(query Queryable)

func (*ScheduleHistoryListByDateParams) Query

func (params *ScheduleHistoryListByDateParams) Query() (expr []bob.Mod[*dialect.SelectQuery])

type ScheduleHistoryListParams

type ScheduleHistoryListParams struct {
	Subreddit string
	Time      time.Time
	Reversed  bool

	Limit int64
}

func (ScheduleHistoryListParams) CountQuery

func (params ScheduleHistoryListParams) CountQuery() (expr []bob.Mod[*dialect.SelectQuery])

func (*ScheduleHistoryListParams) FillFromQuery

func (params *ScheduleHistoryListParams) FillFromQuery(query Queryable)

func (ScheduleHistoryListParams) Query

func (params ScheduleHistoryListParams) Query() (expr []bob.Mod[*dialect.SelectQuery])

type ScheduleHistoryListResult

type ScheduleHistoryListResult struct {
	Schedules models.ScheduleHistorySlice `json:"schedules"`
	Total     int64                       `json:"count"`
}

func (ScheduleHistoryListResult) GetFirst

func (ScheduleHistoryListResult) GetFirstTime

func (result ScheduleHistoryListResult) GetFirstTime() time.Time

func (ScheduleHistoryListResult) GetLast

func (ScheduleHistoryListResult) GetLastTime

func (result ScheduleHistoryListResult) GetLastTime() time.Time

func (ScheduleHistoryListResult) SplitByDay

func (result ScheduleHistoryListResult) SplitByDay() (out []ScheduleHistoryListResultDay)

type ScheduleHistoryListResultDay

type ScheduleHistoryListResultDay struct {
	Date time.Time `json:"date"`
	ScheduleHistoryListResult
}

func (ScheduleHistoryListResultDay) GetLast

type ScheduleSetParams

type ScheduleSetParams struct {
	Subreddit    string
	Status       ScheduleStatus
	ErrorMessage string
}

type ScheduleStatus

type ScheduleStatus int8
const (
	ScheduleStatusDisabled ScheduleStatus = iota
	ScheduleStatusEnabled
	ScheduleStatusStandby
	ScheduleStatusEnqueued
	ScheduleStatusDownloading
	ScheduleStatusError
)

func (ScheduleStatus) Int8

func (ss ScheduleStatus) Int8() int8

func (ScheduleStatus) String

func (ss ScheduleStatus) String() string

type SubredditCheckParam

type SubredditCheckParam = reddit.CheckSubredditParams

type SubredditEditParams

type SubredditEditParams struct {
	Name           string
	EnableSchedule *int32
	Schedule       *string
	Countback      *int32
}

type SubredditGetByNameImageParams

type SubredditGetByNameImageParams struct {
	Q       string
	Limit   int64
	Offset  int64
	OrderBy string
	Sort    string
	NSFW    int
	After   time.Time
	Device  string
}

func (*SubredditGetByNameImageParams) CountQuery

func (sgb *SubredditGetByNameImageParams) CountQuery() (expr []bob.Mod[*dialect.SelectQuery])

func (*SubredditGetByNameImageParams) FillFromQuery

func (sgb *SubredditGetByNameImageParams) FillFromQuery(query Queryable)

func (SubredditGetByNameImageParams) IntoQuery

func (sgb SubredditGetByNameImageParams) IntoQuery() url.Values

func (SubredditGetByNameImageParams) IntoQueryWith

func (sgb SubredditGetByNameImageParams) IntoQueryWith(keyValue ...string) url.Values

func (*SubredditGetByNameImageParams) Query

func (sgb *SubredditGetByNameImageParams) Query() (expr []bob.Mod[*dialect.SelectQuery])

type SubredditGetByNameImageResult

type SubredditGetByNameImageResult struct {
	Subreddit *models.Subreddit
	Images    models.ImageSlice
	Total     int64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL