README updates

Signed-off-by: Kris Nóva <kris@nivenly.com>
main
Kris Nóva 2021-02-11 18:11:05 -08:00
parent 94dde03103
commit cc6c897160
2 changed files with 31 additions and 29 deletions

View File

@ -1,7 +1,8 @@
# Photoprism Client Go # Photoprism Client Go
Go client for the Photoprism Application. Go client for the Photoprism Application.
*Author*: Kris Nóva <kris@nivenly.com>
**Author**: [Kris Nóva](https://github.com/kris-nova) <kris@nivenly.com>
--- ---
@ -16,35 +17,36 @@ go get github.com/kris-nova/photoprism-client-go
# Supported Methods # Supported Methods
```go ```go
func New(connURL *url.URL, token, downloadToken string) *V1Client
func (v1 *V1Client) AddPhotosToAlbum(albumUUID string, photoIDs []string) error
func (v1 *V1Client) ApprovePhoto(uuid string) error
func (v1 *V1Client) CancelIndex() error
func (v1 *V1Client) CloneAlbum(album Album) (Album, error)
func (v1 *V1Client) CreateAlbum(album Album) (Album, error)
func (v1 *V1Client) DeleteAlbums(albumUUIDs []string) error
func (v1 *V1Client) DELETE(payload interface{}, endpointFormat string, a ...interface{}) *V1Response
func (v1 *V1Client) DeletePhotosFromAlbum(albumUUID string, photoIDs []string) error
func (v1 *V1Client) DislikeAlbum(uuid string) error
func (v1 *V1Client) DislikePhoto(uuid string) error
func (v1 *V1Client) Endpoint(str string) string
func (v1 *V1Client) GetAlbumDownload(uuid string) ([]byte, error)
func (v1 *V1Client) GetAlbums(options *AlbumOptions) ([]Album, error) func (v1 *V1Client) GetAlbums(options *AlbumOptions) ([]Album, error)
func (v1 *V1Client) GetAlbum(uuid string) (Album, error) func (v1 *V1Client) GetAlbum(uuid string) (Album, error)
func (v1 *V1Client) CreateAlbum(album Album) (Album, error)
func (v1 *V1Client) UpdateAlbum(album Album) (Album, error)
func (v1 *V1Client) DeleteAlbums(albumUUIDs []string) error
func (v1 *V1Client) LikeAlbum(uuid string) error
func (v1 *V1Client) DislikeAlbum(uuid string) error
func (v1 *V1Client) CloneAlbum(album Album) (Album, error)
func (v1 *V1Client) AddPhotosToAlbum(albumUUID string, photoIDs []string) error
func (v1 *V1Client) DeletePhotosFromAlbum(albumUUID string, photoIDs []string) error
func (v1 *V1Client) GetAlbumDownload(uuid string) ([]byte, error)
func New(connURL *url.URL, token, downloadToken string) *V1Client
func (v1 *V1Client) GET(endpointFormat string, a ...interface{}) *V1Response func (v1 *V1Client) GET(endpointFormat string, a ...interface{}) *V1Response
func (v1 *V1Client) GetPhotoDownload(uuid string) ([]byte, error)
func (v1 *V1Client) GetPhotos(options *PhotoOptions) ([]Photo, error)
func (v1 *V1Client) GetPhoto(uuid string) (Photo, error)
func (v1 *V1Client) GetPhotoYaml(uuid string) ([]byte, error)
func (v1 *V1Client) Index() error
func (v1 *V1Client) LikeAlbum(uuid string) error
func (v1 *V1Client) LikePhoto(uuid string) error
func (v1 *V1Client) PhotoPrimary(uuid, fileuuid string) error
func (v1 *V1Client) POST(payload interface{}, endpointFormat string, a ...interface{}) *V1Response func (v1 *V1Client) POST(payload interface{}, endpointFormat string, a ...interface{}) *V1Response
func (v1 *V1Client) PUT(payload interface{}, endpointFormat string, a ...interface{}) *V1Response func (v1 *V1Client) PUT(payload interface{}, endpointFormat string, a ...interface{}) *V1Response
func (v1 *V1Client) DELETE(payload interface{}, endpointFormat string, a ...interface{}) *V1Response
func (v1 *V1Client) Endpoint(str string) string
func (v1 *V1Client) SetToken(token string) func (v1 *V1Client) SetToken(token string)
func (v1 *V1Client) Index() error func (v1 *V1Client) UpdateAlbum(album Album) (Album, error)
func (v1 *V1Client) CancelIndex() error
func (v1 *V1Client) GetPhoto(uuid string) (Photo, error)
func (v1 *V1Client) GetPhotos(options *PhotoOptions) ([]Photo, error)
func (v1 *V1Client) UpdatePhoto(photo Photo) (Photo, error) func (v1 *V1Client) UpdatePhoto(photo Photo) (Photo, error)
func (v1 *V1Client) GetPhotoDownload(uuid string) ([]byte, error)
func (v1 *V1Client) GetPhotoYaml(uuid string) ([]byte, error)
func (v1 *V1Client) ApprovePhoto(uuid string) error
func (v1 *V1Client) LikePhoto(uuid string) error
func (v1 *V1Client) DislikePhoto(uuid string) error
func (v1 *V1Client) PhotoPrimary(uuid, fileuuid string) error
``` ```
# Example Usage # Example Usage
@ -61,13 +63,13 @@ import (
"github.com/kris-nova/logger" "github.com/kris-nova/logger"
) )
func main() { func main()
logger.Level = 4 logger.Level = 4
uuid := "pqnzigq351j2fqgn" // This is a known ID uuid := "pqnzigq351j2fqgn" // This is a known ID
client := photoprism.New("http://localhost:8080") client := photoprism.New("http://localhost:8080")
err := client.Auth(photoprism.NewClientAuthLogin("admin", "missy")) err := client.Auth(photoprism.NewClientAuthLogin("admin", "missy"))
if err != nil { if err != nil
logger.Critical("Error logging into API: %v", err) logger.Critical("Error logging into API: %v", err)
os.Exit(1) os.Exit(1)
} }
@ -76,7 +78,7 @@ func main() {
// GetPhoto() // GetPhoto()
// //
photo, err := client.V1().GetPhoto(uuid) photo, err := client.V1().GetPhoto(uuid)
if err != nil { if err != nil
logger.Critical("Error fetching photo: %v", err) logger.Critical("Error fetching photo: %v", err)
os.Exit(1) os.Exit(1)
} }
@ -86,7 +88,7 @@ func main() {
// //
photo.PhotoTitle = "A really great photo!" photo.PhotoTitle = "A really great photo!"
photo, err = client.V1().UpdatePhoto(photo) photo, err = client.V1().UpdatePhoto(photo)
if err != nil { if err != nil
logger.Critical("Error updating photo: %v", err) logger.Critical("Error updating photo: %v", err)
os.Exit(1) os.Exit(1)
} }
@ -95,12 +97,12 @@ func main() {
// GetPhotoDownload() // GetPhotoDownload()
// //
file, err := client.V1().GetPhotoDownload(photo.UUID) file, err := client.V1().GetPhotoDownload(photo.UUID)
if err != nil { if err != nil
logger.Critical("Error getting photo download: %v", err) logger.Critical("Error getting photo download: %v", err)
os.Exit(1) os.Exit(1)
} }
for _, f := range photo.Files { for _, f := range photo.Files
fileName := fmt.Sprintf("/tmp/%s", path.Base(f.FileName)) fileName := fmt.Sprintf("/tmp/%s", path.Base(f.FileName))
logger.Always(fileName) logger.Always(fileName)
ioutil.WriteFile(fileName, file, 0666) ioutil.WriteFile(fileName, file, 0666)