Documentation ¶
Index ¶
- Variables
- func WithCache(s Cache) option
- func WithRepository(s Repository) option
- type Album
- type Cache
- type CachedAlbumsService
- func (s CachedAlbumsService) AddMediaItems(ctx context.Context, albumId string, mediaItemIds []string) error
- func (s CachedAlbumsService) Create(ctx context.Context, title string) (*Album, error)
- func (s CachedAlbumsService) GetById(ctx context.Context, albumId string) (*Album, error)
- func (s CachedAlbumsService) GetByTitle(ctx context.Context, title string) (*Album, error)
- func (s CachedAlbumsService) List(ctx context.Context) ([]Album, error)
- func (s CachedAlbumsService) RemoveMediaItems(ctx context.Context, albumId string, mediaItemIds []string) error
- type CachitaCache
- func (c CachitaCache) GetAlbum(ctx context.Context, title string) (Album, error)
- func (c CachitaCache) InvalidateAlbum(ctx context.Context, title string) error
- func (c CachitaCache) InvalidateAllAlbums(ctx context.Context) error
- func (c CachitaCache) PutAlbum(ctx context.Context, album Album) error
- func (c CachitaCache) PutManyAlbums(ctx context.Context, albums []Album) error
- type Option
- type Options
- type PhotosLibraryAlbumsRepository
- func (r PhotosLibraryAlbumsRepository) AddManyItems(ctx context.Context, albumId string, mediaItemIds []string) error
- func (r PhotosLibraryAlbumsRepository) Create(ctx context.Context, title string) (*Album, error)
- func (r PhotosLibraryAlbumsRepository) Get(ctx context.Context, albumId string) (*Album, error)
- func (r PhotosLibraryAlbumsRepository) GetByTitle(ctx context.Context, title string) (*Album, error)
- func (r PhotosLibraryAlbumsRepository) ListAll(ctx context.Context) ([]Album, error)
- func (r PhotosLibraryAlbumsRepository) ListWithOptions(ctx context.Context, options Options) ([]Album, error)
- func (r PhotosLibraryAlbumsRepository) RemoveManyItems(ctx context.Context, albumId string, mediaItemIds []string) error
- func (r PhotosLibraryAlbumsRepository) URL() string
- type PhotosLibraryClient
- type Repository
Constants ¶
This section is empty.
Variables ¶
var ( // NullAlbum is a zero value Album. NullAlbum = Album{} ErrAlbumNotFound = errors.New("album not found") )
var ( // ErrCacheMiss is returned when the item does not exist in the cache. ErrCacheMiss = errors.New("item could not be found in the cache") )
Functions ¶
func WithRepository ¶
func WithRepository(s Repository) option
WithRepository configures the Google Photos repository.
Types ¶
type Album ¶
type Album struct { ID string Title string ProductURL string IsWriteable bool MediaItemsCount string CoverPhotoBaseURL string CoverPhotoMediaItemID string }
Album represents a Google Photos album. See: https://developers.google.com/photos/library/reference/rest/v1/albums
type Cache ¶
type Cache interface { // GetAlbum returns Album data from the cache corresponding to the specified title. // It will return ErrCacheMiss if there is no cached Album. GetAlbum(ctx context.Context, title string) (Album, error) // PutAlbum stores the Album data in the cache using the title as key. // Underlying implementations may use any data storage format, // as long as the reverse operation, GetAlbum, results in the original data. PutAlbum(ctx context.Context, album Album) error // PutManyAlbums stores many Album data in the cache using the title as key. PutManyAlbums(ctx context.Context, albums []Album) error // InvalidateAlbum removes the Album data from the cache corresponding to the specified title. // If there's no such Album in the cache, it will return nil. InvalidateAlbum(ctx context.Context, title string) error // InvalidateAllAlbums removes all key corresponding to albums InvalidateAllAlbums(ctx context.Context) error }
Cache is used to store and retrieve previously obtained objects.
type CachedAlbumsService ¶
type CachedAlbumsService struct {
// contains filtered or unexported fields
}
CachedAlbumsService implements a albums Google Photos client with cached results.
func NewCachedAlbumsService ¶
func NewCachedAlbumsService(authenticatedClient *http.Client, options ...Option) *CachedAlbumsService
NewCachedAlbumsService returns an albums Google Photos client with cached results. The authenticatedClient should have all oAuth credentials in place.
func (CachedAlbumsService) AddMediaItems ¶
func (s CachedAlbumsService) AddMediaItems(ctx context.Context, albumId string, mediaItemIds []string) error
AddMediaItems adds multiple media item(s) to the specified album.
func (CachedAlbumsService) GetById ¶
GetById fetches and caches an album from the repo by id. It does not use the cache to look for it. Returns ErrAlbumNotFound if the album does not exist.
func (CachedAlbumsService) GetByTitle ¶
GetByTitle fetches and caches an album from the repo by title. It tries to find it in the cache, first. Returns ErrAlbumNotFound if the album does not exist.
func (CachedAlbumsService) List ¶
func (s CachedAlbumsService) List(ctx context.Context) ([]Album, error)
List fetches and caches all the albums from the repo.
func (CachedAlbumsService) RemoveMediaItems ¶
func (s CachedAlbumsService) RemoveMediaItems(ctx context.Context, albumId string, mediaItemIds []string) error
RemoveMediaItems removes multiple media item(s) from the specified album.
type CachitaCache ¶
type CachitaCache struct {
// contains filtered or unexported fields
}
CachitaCache implements Cache with `gadelkareem/cachita` package.
func NewCachitaCache ¶
func NewCachitaCache() *CachitaCache
NewCachitaCache returns a Cache service implemented using `gadelkareem/cachita`.
func (CachitaCache) InvalidateAlbum ¶
func (c CachitaCache) InvalidateAlbum(ctx context.Context, title string) error
InvalidateAlbum removes the specified Album from the cache.
func (CachitaCache) InvalidateAllAlbums ¶
func (c CachitaCache) InvalidateAllAlbums(ctx context.Context) error
InvalidateAllAlbums removes all albums from the cache.
func (CachitaCache) PutAlbum ¶
func (c CachitaCache) PutAlbum(ctx context.Context, album Album) error
PutAlbum store an object data to the cache.
func (CachitaCache) PutManyAlbums ¶
func (c CachitaCache) PutManyAlbums(ctx context.Context, albums []Album) error
PutManyAlbums store many objects data to the cache.
type Option ¶
type Option interface { Name() string Value() interface{} }
Option represents a configurable parameter.
type Options ¶ added in v2.4.0
type Options struct { // ExcludeNonAppCreatedData excludes albums that were not created by this app. // Defaults to false (all albums are returned). ExcludeNonAppCreatedData bool }
Options defines the options that could be customized when listing albums.
type PhotosLibraryAlbumsRepository ¶ added in v2.1.0
type PhotosLibraryAlbumsRepository struct {
// contains filtered or unexported fields
}
PhotosLibraryAlbumsRepository represents an albums Google Photos repository.
func NewPhotosLibraryClient ¶ added in v2.1.0
func NewPhotosLibraryClient(authenticatedClient *http.Client) (*PhotosLibraryAlbumsRepository, error)
NewPhotosLibraryClient returns a Repository using PhotosLibrary service.
func NewPhotosLibraryClientWithURL ¶ added in v2.1.0
func NewPhotosLibraryClientWithURL(authenticatedClient *http.Client, url string) (*PhotosLibraryAlbumsRepository, error)
NewPhotosLibraryClientWithURL returns a Repository using PhotosLibrary service with a custom URL.
func (PhotosLibraryAlbumsRepository) AddManyItems ¶ added in v2.1.0
func (r PhotosLibraryAlbumsRepository) AddManyItems(ctx context.Context, albumId string, mediaItemIds []string) error
AddManyItems adds multiple media item(s) to the specified album.
func (PhotosLibraryAlbumsRepository) Create ¶ added in v2.1.0
Create adds and caches a new album to the repo.
func (PhotosLibraryAlbumsRepository) Get ¶ added in v2.1.0
Get fetches and caches an album from the repo by id.
func (PhotosLibraryAlbumsRepository) GetByTitle ¶ added in v2.1.0
func (r PhotosLibraryAlbumsRepository) GetByTitle(ctx context.Context, title string) (*Album, error)
GetByTitle fetches and caches an album from the repo by title.
func (PhotosLibraryAlbumsRepository) ListAll ¶ added in v2.1.0
func (r PhotosLibraryAlbumsRepository) ListAll(ctx context.Context) ([]Album, error)
ListAll fetches all the albums from the repo.
func (PhotosLibraryAlbumsRepository) ListWithOptions ¶ added in v2.4.0
func (r PhotosLibraryAlbumsRepository) ListWithOptions(ctx context.Context, options Options) ([]Album, error)
ListWithOptions fetches all the albums from the repo with provided options. Options would customize the listing.
func (PhotosLibraryAlbumsRepository) RemoveManyItems ¶ added in v2.1.0
func (r PhotosLibraryAlbumsRepository) RemoveManyItems(ctx context.Context, albumId string, mediaItemIds []string) error
RemoveManyItems removes multiple media item(s) from the specified album.
func (PhotosLibraryAlbumsRepository) URL ¶ added in v2.1.0
func (r PhotosLibraryAlbumsRepository) URL() string
URL returns the albums repository url.
type PhotosLibraryClient ¶ added in v2.1.0
type PhotosLibraryClient interface { BatchAddMediaItems(albumId string, albumBatchAddMediaItemsRequest *photoslibrary.AlbumBatchAddMediaItemsRequest) *photoslibrary.AlbumBatchAddMediaItemsCall Create(createAlbumRequest *photoslibrary.CreateAlbumRequest) *photoslibrary.AlbumsCreateCall Get(albumId string) *photoslibrary.AlbumsGetCall List() *photoslibrary.AlbumsListCall }
PhotosLibraryClient represents an albums using `gphotosuploader/googlemirror/api/photoslibrary`.
type Repository ¶
type Repository interface { AddManyItems(ctx context.Context, albumId string, mediaItemIds []string) error RemoveManyItems(ctx context.Context, albumId string, mediaItemIds []string) error Create(ctx context.Context, title string) (*Album, error) Get(ctx context.Context, albumId string) (*Album, error) ListAll(ctx context.Context) ([]Album, error) GetByTitle(ctx context.Context, title string) (*Album, error) }
Repository represents an album repository.