2021-02-11 20:53:01 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2021-05-05 16:18:05 +02:00
|
|
|
"github.com/astravexton/logger"
|
|
|
|
photoprism "github.com/astravexton/photoprism-client-go"
|
|
|
|
"github.com/astravexton/photoprism-client-go/api/v1"
|
2021-02-11 20:53:01 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
// ---
|
|
|
|
// Log Level 4 (Most)
|
|
|
|
// Log Level 3
|
|
|
|
// Log Level 2
|
|
|
|
// Log Level 1
|
|
|
|
// Log Level 0 (Least)
|
|
|
|
//
|
|
|
|
logger.Level = 4
|
|
|
|
//
|
|
|
|
// ---
|
|
|
|
|
|
|
|
client := photoprism.New("http://localhost:8080")
|
|
|
|
err := client.Auth(photoprism.NewClientAuthLogin("admin", "missy"))
|
|
|
|
if err != nil {
|
|
|
|
halt(4, "Error logging into API: %v", err)
|
|
|
|
}
|
|
|
|
logger.Always("Logged in...")
|
|
|
|
|
2021-02-12 00:32:03 +01:00
|
|
|
album := api.Album{
|
|
|
|
AlbumTitle: "NovaAlbum",
|
2021-02-11 23:21:44 +01:00
|
|
|
}
|
2021-02-11 20:53:01 +01:00
|
|
|
|
2021-02-12 00:32:03 +01:00
|
|
|
newAlbum, err := client.V1().CreateAlbum(album)
|
2021-02-11 23:21:44 +01:00
|
|
|
if err != nil {
|
2021-02-12 00:32:03 +01:00
|
|
|
halt(2, "Error creating album: %v", err)
|
2021-02-11 23:21:44 +01:00
|
|
|
}
|
|
|
|
|
2021-02-12 00:32:03 +01:00
|
|
|
err = client.V1().DeleteAlbums([]string{newAlbum.AlbumUID})
|
|
|
|
if err != nil {
|
|
|
|
halt(1, "Error deleting album: %v", err)
|
|
|
|
}
|
2021-02-11 20:53:01 +01:00
|
|
|
}
|