api

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2020 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database added in v0.0.2

type Database interface {
	// Arists
	MusicAristsCreate(artist *dbmodels.Artist) (*dbmodels.Artist, error)
	MusicAristsGetList(start, count int64, orderBy []string) ([]*dbmodels.Artist, error)
	MusicAristsSearchByName(start, count int64, orderBy []string, name string) ([]*dbmodels.Artist, error)
	MusicAristsGet(artistID int64) (*dbmodels.Artist, error)
	MusicAristsDelete(artistID int64) error
	MusicAristsUpdateTexts(artist *dbmodels.Artist) error
	MusicAristsUpdateImage(artistID int64, image string) error
	MusicAristsAppendTrack(artistID, trackID int64) error
	MusicAristsDeleteTrack(artistID, trackID int64) error

	// Albums
	MusicAlbumsCreate(album *dbmodels.Album) (*dbmodels.Album, error)
	MusicAlbumsGetList(start, count int64, orderBy []string) ([]*dbmodels.AlbumWithArtists, error)
	MusicAlbumsSearchByName(start, count int64, orderBy []string, name string) ([]*dbmodels.AlbumWithArtists, error)
	MusicAlbumsGet(albumID int64) (*dbmodels.AlbumWithArtists, error)
	MusicAlbumsDelete(albumID int64) error
	MusicAlbumsGetListByArtist(artistID int64, orderBy []string) ([]*dbmodels.Album, error)
	MusicAlbumsUpdateTexts(album *dbmodels.Album) error
	MusicAlbumsUpdateImage(albumID int64, image string) error

	// Tracks
	MusicTracksGetList(start, count int64, orderBy []string) ([]*dbmodels.TrackWithAlbumArtists, error)
	MusicTracksSearchByName(start, count int64, orderBy []string, name string) ([]*dbmodels.TrackWithAlbumArtists, error)
	MusicTracksGet(trackID int64) (*dbmodels.TrackWithGenresAlbumArtists, error)
	MusicTracksDelete(trackID int64) error
	MusicTracksGetListByArtist(artistID int64, orderBy []string) ([]*dbmodels.TrackWithAlbumArtists, error)
	MusicTracksGetListByAlbum(albumID int64, orderBy []string) ([]*dbmodels.TrackWithAlbumArtists, error)
	MusicTracksUpdateTexts(track *dbmodels.Track) error
	MusicTracksUpdateAlbum(trackID, albumID int64) error

	// Genres
	MusicGenresCreate(genre *dbmodels.Genre) (*dbmodels.Genre, error)
	MusicGenresGetList(orderBy []string) ([]*dbmodels.Genre, error)
	MusicGenresGet(genreID int64) (*dbmodels.Genre, error)
	MusicGenresDelete(genreID int64) error
	MusicGenresGetArtists(start, count, genreID int64, orderBy []string) ([]*dbmodels.Artist, error)
	MusicGenresGetAlbums(start, count, genreID int64, orderBy []string) ([]*dbmodels.AlbumWithArtists, error)
	MusicGenresGetTracks(start, count, genreID int64, orderBy []string) ([]*dbmodels.TrackWithAlbumArtists, error)
	MusicGenresUpdateTexts(genre *dbmodels.Genre) error
	MusicGenresAppendTrack(genreID, trackID int64) error
	MusicGenresDeleteTrack(genreID, trackID int64) error

	// Tags
	MusicTagsCreate(tag *dbmodels.Tag) (*dbmodels.Tag, error)
	MusicTagsGetList(orderBy []string) ([]*dbmodels.TagWithVariants, error)
	MusicTagsSearchByName(orderBy []string, name string) ([]*dbmodels.TagWithVariants, error)
	MusicTagsGetListByArtist(artistID int64, orderBy []string) ([]*dbmodels.Tag, error)
	MusicTagsGetListByAlbum(albumID int64, orderBy []string) ([]*dbmodels.Tag, error)
	MusicTagsGetListByTrack(trackID int64, orderBy []string) ([]*dbmodels.Tag, error)
	MusicTagsGet(tagID int64) (*dbmodels.Tag, error)
	MusicTagsDelete(tagID int64) error
	MusicTagsUpdateTexts(tag *dbmodels.Tag) error
	MusicTagsAppendArtist(tagID, artistID int64) error
	MusicTagsDeleteArtist(tagID, artistID int64) error
	MusicTagsAppendAlbum(tagID, albumID int64) error
	MusicTagsDeleteAlbum(tagID, albumID int64) error
	MusicTagsAppendTrack(tagID, trackID int64) error
	MusicTagsDeleteTrack(tagID, trackID int64) error
	MusicTagsGetArtists(start, count int64, tags, notTags []int64, orderBy []string) ([]*dbmodels.Artist, error)
	MusicTagsGetAlbums(start, count int64, tags, notTags []int64, orderBy []string) ([]*dbmodels.AlbumWithArtists, error)
	MusicTagsGetTracks(start, count int64, tags, nt []int64, orderBy []string) ([]*dbmodels.TrackWithAlbumArtists, error)

	// Tasks
	TasksGetListByUser(start, count, userID int64, orderBy []string) ([]*dbmodels.Task, error)
	TasksGet(taskID, userID int64) (*dbmodels.Task, error)

	// Setings
	SettingsGetList() (map[string]string, error)
	SettingsUpdateList(setsData map[string]string) error
}

Database with methods of the restapi

type Server

type Server struct {
	SettingsManager *settings.Settings
	// contains filtered or unexported fields
}

Server is a http server

func NewServer

func NewServer(conf *config.RestAPI, logger *zerolog.Logger, db Database, st Storage, ts Tasker) *Server

NewServer creates new server

func (*Server) ApplySettings added in v0.0.2

func (s *Server) ApplySettings(sets interface{}) error

func (*Server) CheckSettingsIsValid added in v0.0.2

func (*Server) CheckSettingsIsValid(sets interface{}) error

CheckSettingsIsValid checks is this settings valid

func (*Server) GetSettingsPrefix added in v0.0.2

func (*Server) GetSettingsPrefix() string

GetSettingsPrefix returns prefix of the settings name

func (*Server) Run

func (s *Server) Run() error

Run runs http server. It takes context channel to catch a stop signal

func (*Server) Shutdown

func (s *Server) Shutdown(wait time.Duration)

Shutdown http server gracefully

type Storage

type Storage interface {
	// SaveToTmp saves file to the tmp storage
	SaveToTmp(src io.Reader, ext string) (string, error)
	// RemoveTmpFile removes file in the tmp storage
	RemoveTmpFile(fileName string) error
}

Storage is a file system storage

type Tasker

type Tasker interface {
	// ProcessMusicFile creates a new task and returns its identifier
	// Takes name of the file to parse and User ID
	ProcessMusicFile(log *zerolog.Logger, fileName string, userID int64, sets ...*tasker.ProcessSettings) (
		taskID int64, res <-chan error, err error)

	// ProcessImageFile processes and creates new image file
	// returns name of the new file
	ProcessImageFile(log *zerolog.Logger, fileName string) (string, error)
}

Tasker contains methods processing of files

Directories

Path Synopsis
mapping

Jump to

Keyboard shortcuts

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