Documentation
¶
Index ¶
- Constants
- Variables
- func AddOrUpdateCustomDataToChannel(thinger Thinger, channel Channel, user User, data string) error
- func AddOrUpdateCustomDataToVideo(thinger Thinger, video Video, user User, data string) error
- func AppendCollectionItem(thinger Thinger, user User, collectionID, itemID uuid.UUID) error
- func GetUserChannelCustomData(thinger Thinger, channel Channel, user User) (string, error)
- func GetUserCollectionCustomData(thinger Thinger, collection Collection, user User) (string, error)
- func GetUserVideoCustomData(thinger Thinger, video Video, user User) (string, error)
- func InsertCollectionItem(thinger Thinger, user User, collectionID, itemID uuid.UUID, itemPos int) error
- func LinkChannelToUser(thinger Thinger, channel Channel, user User, details string) error
- func LinkCollectionToUser(thinger Thinger, collection Collection, user User, details string) error
- func LinkVideoToUser(thinger Thinger, video Video, user User, details string) error
- func PlaylistVideos(c YoutubeClient, id string) ([]string, error)
- func RemoveAllCollectionItems(thinger Thinger, collectionID uuid.UUID) error
- func RemoveChannelByID(thinger Thinger, id uuid.UUID) error
- func RemoveCollectionByID(thinger Thinger, id uuid.UUID) error
- func RemoveCollectionItem(thinger Thinger, user User, collectionID uuid.UUID, itemPos int) error
- func RemoveUserByID(thinger Thinger, id uuid.UUID) error
- func RemoveUserChannelCustomData(thinger Thinger, channel Channel, user User) error
- func RemoveUserCollectionCustomData(thinger Thinger, collection Collection, user User) error
- func RemoveUserVideoCustomData(thinger Thinger, video Video, user User) error
- func RemoveVideoByID(thinger Thinger, id uuid.UUID) error
- func ScorchedEarth(store Thinger, delUser bool)
- func UnlinkChannelAndUser(thinger Thinger, channel Channel, user User) error
- func UnlinkCollectionAndUser(thinger Thinger, collection Collection, user User) error
- func UnlinkVideoAndUser(thinger Thinger, video Video, user User) error
- func UnpublishCollection(thinger Thinger, tuber Tuber, id uuid.UUID) error
- func UpdateCollectionCustomData(thinger Thinger, collection Collection, user User, data string) error
- func UpdateCollectionItem(thinger Thinger, user User, collectionID, itemID uuid.UUID, itemPos int) (err error)
- func UpdateCollectionItems(thinger Thinger, user User, items CollectionItems) error
- func UpdateUser(thinger Thinger, user User) error
- type BulkItemError
- type Channel
- func AddChannel(thinger Thinger, tuber Tuber, id string) (channel Channel, err error)
- func GetChannelByID(thinger Thinger, user User, id uuid.UUID) (Channel, error)
- func GetChannelByReferenceID(thinger Thinger, user User, refID string) (Channel, error)
- func GetChannelsByUser(thinger Thinger, user User) ([]Channel, error)
- type Collection
- func AddCollection(thinger Thinger, tuber Tuber, user User, id string) (collection Collection, err error)
- func CreateCollection(thinger Thinger, collection Collection, user User) (Collection, error)
- func GetCollectionByID(thinger Thinger, user User, id uuid.UUID) (Collection, error)
- func GetCollectionByReferenceID(thinger Thinger, user User, refID string) (Collection, error)
- func GetCollectionsByUser(thinger Thinger, user User) ([]Collection, error)
- func PublishCollection(thinger Thinger, tuber Tuber, user User, id uuid.UUID) (collection Collection, err error)
- func UpdateCollection(thinger Thinger, collection Collection, user User) (Collection, error)
- type CollectionItem
- type CollectionItems
- type Librarian
- type Option
- type Thing
- type ThingNotFoundError
- type ThingNotLinkedError
- type Thinger
- type Tuber
- type User
- type UserNotLinkedError
- type Video
- func AddVideo(thinger Thinger, tuber Tuber, id string) (video Video, err error)
- func GetVideoByID(thinger Thinger, user User, id uuid.UUID) (Video, error)
- func GetVideoByReferenceID(thinger Thinger, user User, refID string) (Video, error)
- func GetVideosByReferenceIDs(thinger Thinger, user User, refIDs []string) ([]Video, error)
- func GetVideosByUser(thinger Thinger, user User) ([]Video, error)
- type YoutubeClient
- func (c YoutubeClient) ChannelDetails(id string) (channelThing, error)
- func (c YoutubeClient) ChannelPlaylists(channelID string) ([]collectionThing, error)
- func (c YoutubeClient) MyPlaylists() ([]YoutubePlaylist, error)
- func (c YoutubeClient) PlaylistDelete(id string) error
- func (c YoutubeClient) PlaylistDetails(id string) (collectionThing, error)
- func (c YoutubeClient) PlaylistInsert(collection collectionThing) (string, error)
- func (c YoutubeClient) PlaylistUpdate(collection collectionThing) error
- func (c YoutubeClient) PlaylistVideoDelete(playlistID, videoID string, pos int64) error
- func (c YoutubeClient) PlaylistVideoInsert(playlistID, videoID string, pos int64) error
- func (c YoutubeClient) PlaylistVideoUpdate(playlistID, videoID string, pos int64) error
- func (c YoutubeClient) PlaylistVideos(id string) ([]string, error)
- func (c YoutubeClient) VideoDetails(id string) (videoThing, error)
- type YoutubePlaylist
Constants ¶
const ( // ItemUser = thingTypeUser ItemVideo = thingTypeVideo ItemChannel = thingTypeChannel ItemCollection = thingTypeCollection )
Item types
Variables ¶
var ErrCreateConflict = errors.New("cannot create duplicate item")
Functions ¶
func AddOrUpdateCustomDataToChannel ¶
AddOrUpdateCustomDataToChannel links the given data to a Channel on behalf of a User
func AddOrUpdateCustomDataToVideo ¶
AddOrUpdateCustomDataToVideo links the given data to a Video on behalf of a User
func AppendCollectionItem ¶
AppendCollectionItem adds an item to the end of a collection
func GetUserChannelCustomData ¶
GetUserChannelCustomData retrieves the given data to a Channel on behalf of a User
func GetUserCollectionCustomData ¶
func GetUserCollectionCustomData(thinger Thinger, collection Collection, user User) (string, error)
GetUserCollectionCustomData retrieves the given data to a Collection on behalf of a User
func GetUserVideoCustomData ¶
GetUserVideoCustomData retrieves the given data to a Video on behalf of a User
func InsertCollectionItem ¶
func InsertCollectionItem(thinger Thinger, user User, collectionID, itemID uuid.UUID, itemPos int) error
InsertCollectionItem adds an item to a collection
func LinkChannelToUser ¶
LinkChannelToUser adds a relationship between a channel and a user
func LinkCollectionToUser ¶
func LinkCollectionToUser(thinger Thinger, collection Collection, user User, details string) error
LinkCollectionToUser adds a relationship between a user and a given collection as well as the items
func LinkVideoToUser ¶
LinkVideoToUser adds a relationship between a video and a user
func PlaylistVideos ¶
func PlaylistVideos(c YoutubeClient, id string) ([]string, error)
PlaylistVideos retrieves the IDs of the videos in a playlist
func RemoveAllCollectionItems ¶
RemoveAllCollectionItems removes all items in a collection
func RemoveChannelByID ¶
RemoveChannelByID removes the identified collection from the Thinger
func RemoveCollectionByID ¶
RemoveCollectionByID removes the identified collection from the Thinger
func RemoveCollectionItem ¶
RemoveCollectionItem removes items in a Collection
func RemoveUserByID ¶
RemoveUserByID removes an identified User from the given Thinger
func RemoveUserChannelCustomData ¶
RemoveUserChannelCustomData ... guess what this do!
func RemoveUserCollectionCustomData ¶
func RemoveUserCollectionCustomData(thinger Thinger, collection Collection, user User) error
RemoveUserCollectionCustomData ... guess what this do!
func RemoveUserVideoCustomData ¶
RemoveUserVideoCustomData ... guess what this do!
func RemoveVideoByID ¶
RemoveVideoByID removes the identified collection from the Thinger
func ScorchedEarth ¶
func UnlinkChannelAndUser ¶
UnlinkChannelAndUser removes relationship between a channel and a user
func UnlinkCollectionAndUser ¶
func UnlinkCollectionAndUser(thinger Thinger, collection Collection, user User) error
UnlinkCollectionAndUser removes relationship between a collection and a user
func UnlinkVideoAndUser ¶
UnlinkVideoAndUser removes relationship between a video and a user
func UnpublishCollection ¶
UnpublishCollection inserts or updates the identified collection to the given tuber service
func UpdateCollectionCustomData ¶
func UpdateCollectionCustomData(thinger Thinger, collection Collection, user User, data string) error
UpdateCollectionCustomData links the given data to a Collection on behalf of a User
func UpdateCollectionItem ¶
func UpdateCollectionItem(thinger Thinger, user User, collectionID, itemID uuid.UUID, itemPos int) (err error)
UpdateCollectionItem adds/removes/changes a single collection item
func UpdateCollectionItems ¶
func UpdateCollectionItems(thinger Thinger, user User, items CollectionItems) error
UpdateCollectionItems adds/removes/changes items in a Collection
func UpdateUser ¶
UpdateUser updates an existing User in the given Thinger
Types ¶
type BulkItemError ¶
BulkItemError collects the multiple errors encountered when collecting multiples
func (BulkItemError) Error ¶
func (e BulkItemError) Error() string
type Channel ¶
type Channel struct {
UserLinked bool `json:"userLinked,omitempty"`
Data string `json:"data,omitempty"`
// contains filtered or unexported fields
}
Channel is a reference to a channel along with metadata associated with the requesting user
func AddChannel ¶
AddChannel retrieves channel details from a Tuber and adds a Channel Thing to the given Thinger
func GetChannelByID ¶
GetChannelByID retrieves the collection which matches the given ID
func GetChannelByReferenceID ¶
GetChannelByReferenceID retrieves the user thing by the given external ID
type Collection ¶
type Collection struct {
Data string `json:"data,omitempty"`
// contains filtered or unexported fields
}
Collection is a reference to a channel along with metadata associated with the requesting user
func AddCollection ¶
func AddCollection(thinger Thinger, tuber Tuber, user User, id string) (collection Collection, err error)
AddCollection retrieves collection details from a Tuber and adds a Collection Thing to the given Thinger
func CreateCollection ¶
func CreateCollection(thinger Thinger, collection Collection, user User) (Collection, error)
CreateCollection creates a new collection in the thinger that is not associated with an external thing
func GetCollectionByID ¶
GetCollectionByID retrieves the collection which matches the given ID
func GetCollectionByReferenceID ¶
func GetCollectionByReferenceID(thinger Thinger, user User, refID string) (Collection, error)
GetCollectionByReferenceID retrieves the user thing by the given external ID
func GetCollectionsByUser ¶
func GetCollectionsByUser(thinger Thinger, user User) ([]Collection, error)
GetCollectionsByUser retrieves the collections which belong to the given user
func PublishCollection ¶
func PublishCollection(thinger Thinger, tuber Tuber, user User, id uuid.UUID) (collection Collection, err error)
PublishCollection inserts or updates the identified collection to the given tuber service
func UpdateCollection ¶
func UpdateCollection(thinger Thinger, collection Collection, user User) (Collection, error)
UpdateCollection updates an existing collection in the thinger
type CollectionItem ¶
type CollectionItem struct {
Kind string `json:"kind"`
ID string `json:"id"`
Position int `json:"position"`
}
CollectionItem defines the minimum data to identify an item in a collection and its position
type CollectionItems ¶
type CollectionItems struct {
CollectionID string `json:"collectionId"`
Items []CollectionItem `json:"items,omitempty"`
Data string `json:"data,omitempty"`
}
CollectionItems collects the items within a collection
func AddCollectionItems ¶
func AddCollectionItems(thinger Thinger, tuber Tuber, user User, collection Collection) (CollectionItems, error)
AddCollectionItems retrieves collection items from a Tuber and adds a Collection Thing to the given Thinger
func GetCollectionItems ¶
func GetCollectionItems(thinger Thinger, collectionID uuid.UUID) (CollectionItems, error)
GetCollectionItems retrieves the collection which matches the given ID
type Librarian ¶
type Librarian struct {
Thinger Thinger
CreateTuber func(token *oauth2.Token) (Tuber, error)
// contains filtered or unexported fields
}
Librarian provides the Thinger and Tuber creator
type Option ¶
type Option func(*Librarian)
Option is a function that configures a Librarian
func WithThinger ¶
WithThinger sets the Thinger for the Librarian
func WithTuberAuth ¶
WithTuberAuth sets the OAuth client id and secret for the Tuber to use
type ThingNotFoundError ¶
ThingNotFoundError is an error thingy that can be checked for when a Thing was not found
func (ThingNotFoundError) Error ¶
func (e ThingNotFoundError) Error() string
type ThingNotLinkedError ¶
ThingNotLinkedError is an error thingy that can be checked for when a Thing was not found
func (*ThingNotLinkedError) Error ¶
func (e *ThingNotLinkedError) Error() string
type Thinger ¶
type Thinger interface {
// AddThing creates a new entity to storage
AddThing(t Thing) error
// UpdateThing updates a new entity in storage
UpdateThing(t Thing) error
// RemoveThing deletes an existing thing from storage
RemoveThing(id string) error
// GetThing returns a single thing instance based on its ID
GetThing(id string) (Thing, error)
// GetThingByReferenceID returns a single thing instance based on its ReferenceID
GetThingByReferenceID(id string) (Thing, error)
// GetThingsByReferenceIDs returns multiple things based on a slice of ReferenceIDs
GetThingsByReferenceIDs(ids []string) ([]Thing, error)
// GetAllThings retrieves every thing
GetAllThings() ([]Thing, error)
// GetAllThingsByType retrieves every thing for the given type
GetAllThingsByType(thingType string) ([]Thing, error)
// MakeRelationship creates a relational entry between two Things
MakeRelationship(parentID, childID, data string) error
// UpdateRelationshipData updates the data associated with the matching parent/child relationships
UpdateRelationshipData(parentID, childID, data string) error
// GetRelationshipData data associated with the matching parent/child relationships
GetRelationshipData(parentID, childID string) (string, error)
// GetParents returns IDs of all Things which are parents of the identified Thing
GetParents(childID string) ([]Thing, error)
// GetChildren returns IDs of all Things which are children of the identified Thing
GetChildren(parentID string) ([]Thing, error)
// BreakRelationship removes a relational entry between two Things
BreakRelationship(parentID, childID string) error
// Close the Thinger connection
Close() error
}
Thinger defines the interface needed by any database client
type Tuber ¶
type Tuber interface {
// VideoDetails returns details associated with the identified video
VideoDetails(id string) (videoThing, error)
// ChannelDetails returns details associated with the identified video
ChannelDetails(id string) (channelThing, error)
// ChannelPlaylists returns all of the playlists for the given channel
ChannelPlaylists(id string) ([]collectionThing, error)
// ChannelVideos returns all of the videos for the given channel
// ChannelVideos(id string) ([]videoThing, error)
// MyPlaylists returns all of the playlists associated with the user the service is created for
MyPlaylists() ([]collectionThing, error)
// playlistDetails returns details associated with the identified playlist
PlaylistDetails(id string) (collectionThing, error)
// PlaylistInsert creates a playlist from the given Collection
PlaylistInsert(collection collectionThing) (string, error)
// PlaylistUpdate updates an existing playlist
PlaylistUpdate(collection collectionThing) error
// PlaylistDelete removes an existing playlist by ID
PlaylistDelete(id string) error
// PlaylistVideos retrieves the videos in a playlist
PlaylistVideos(id string) ([]string, error)
// PlaylistVideoInsert adds a video to a playlist
PlaylistVideoInsert(playlistID, videoID string, pos int64) error
// PlaylistVideoUpdate updates the position of a video
PlaylistVideoUpdate(playlistID, videoID string, pos int64) error
// PlaylistVideoDelete removes a video from a playlist
PlaylistVideoDelete(playlistID, videoID string, pos int64) error
}
Tuber defines the interface needed by the service where videos and stuff will be sourced from
type User ¶
type User struct {
// contains filtered or unexported fields
}
User is a reference to ... user ... data
type UserNotLinkedError ¶
UserNotLinkedError is an error thingy that can be checked for when a Thing was not found
func (UserNotLinkedError) Error ¶
func (e UserNotLinkedError) Error() string
type Video ¶
type Video struct {
UserLinked bool `json:"userLinked,omitempty"`
Data string `json:"data,omitempty"`
// contains filtered or unexported fields
}
Video is a reference to a video along with metadata associated with the requesting user
func GetVideoByID ¶
GetVideoByID retrieves the collection which matches the given ID
func GetVideoByReferenceID ¶
GetVideoByReferenceID retrieves the user thing by the given external ID
func GetVideosByReferenceIDs ¶
GetVideosByReferenceIDs retrieves the user thing by the given external IDs
type YoutubeClient ¶
type YoutubeClient struct {
// contains filtered or unexported fields
}
YoutubeClient is a Tuber implementation that communicates with YouTube
func NewYoutubeClient ¶
func NewYoutubeClient(clientID, secret string, token *oauth2.Token) (*YoutubeClient, error)
NewYoutubeClient creates an instance of the YouTube Service for the given user
func (YoutubeClient) ChannelDetails ¶
func (c YoutubeClient) ChannelDetails(id string) (channelThing, error)
ChannelDetails returns details associated with the identified video
func (YoutubeClient) ChannelPlaylists ¶
func (c YoutubeClient) ChannelPlaylists(channelID string) ([]collectionThing, error)
ChannelPlaylists returns all of the playlists for the given channel
func (YoutubeClient) MyPlaylists ¶
func (c YoutubeClient) MyPlaylists() ([]YoutubePlaylist, error)
myPlaylists returns all of the playlists associated with the user the service is created for
func (YoutubeClient) PlaylistDelete ¶
func (c YoutubeClient) PlaylistDelete(id string) error
PlaylistDelete removes an existing playlist by ID
func (YoutubeClient) PlaylistDetails ¶
func (c YoutubeClient) PlaylistDetails(id string) (collectionThing, error)
PlaylistDetails returns details associated with the identified playlist
func (YoutubeClient) PlaylistInsert ¶
func (c YoutubeClient) PlaylistInsert(collection collectionThing) (string, error)
PlaylistInsert creates a playlist from the given Collection
func (YoutubeClient) PlaylistUpdate ¶
func (c YoutubeClient) PlaylistUpdate(collection collectionThing) error
PlaylistUpdate updates an existing playlist's metadata
func (YoutubeClient) PlaylistVideoDelete ¶
func (c YoutubeClient) PlaylistVideoDelete(playlistID, videoID string, pos int64) error
PlaylistVideoDelete removes a video from a playlist
func (YoutubeClient) PlaylistVideoInsert ¶
func (c YoutubeClient) PlaylistVideoInsert(playlistID, videoID string, pos int64) error
PlaylistVideoInsert adds a video to a playlist
func (YoutubeClient) PlaylistVideoUpdate ¶
func (c YoutubeClient) PlaylistVideoUpdate(playlistID, videoID string, pos int64) error
PlaylistVideoUpdate updates the position of a video
func (YoutubeClient) PlaylistVideos ¶
func (c YoutubeClient) PlaylistVideos(id string) ([]string, error)
PlaylistVideos retrieves the IDs of the videos in a playlist
func (YoutubeClient) VideoDetails ¶
func (c YoutubeClient) VideoDetails(id string) (videoThing, error)
VideoDetails returns details associated with the identified video
type YoutubePlaylist ¶
type YoutubePlaylist = collectionThing