2021-01-31 09:08:52 +01:00
|
|
|
package photoprism
|
2021-01-31 07:41:23 +01:00
|
|
|
|
2021-01-31 09:08:52 +01:00
|
|
|
import "github.com/kris-nova/client-go/api/v1"
|
|
|
|
|
|
|
|
type Client struct {
|
|
|
|
v1client *api.V1Client
|
|
|
|
}
|
|
|
|
|
|
|
|
type ClientAuthenticator interface {
|
|
|
|
getKey() string
|
|
|
|
getSecret() string
|
|
|
|
}
|
|
|
|
|
|
|
|
// -- [ ClientAuthLogin ] --
|
|
|
|
|
|
|
|
// TODO We probably want to base64 encode this
|
|
|
|
type ClientAuthLogin struct {
|
|
|
|
user string
|
|
|
|
pass string
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewClientAuthLogin(user, pass string) ClientAuthenticator {
|
|
|
|
return &ClientAuthLogin{
|
|
|
|
user: user,
|
|
|
|
pass: pass,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *ClientAuthLogin) getKey() string {
|
|
|
|
return c.user
|
|
|
|
}
|
|
|
|
func (c *ClientAuthLogin) getSecret() string {
|
|
|
|
return c.pass
|
2021-01-31 07:41:23 +01:00
|
|
|
}
|
|
|
|
|
2021-01-31 09:08:52 +01:00
|
|
|
// -- [ ClientAuthToken ] --
|
|
|
|
|
|
|
|
// TODO We probably want to base64 encode this
|
|
|
|
type ClientAuthToken struct {
|
|
|
|
key string
|
|
|
|
secret string
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewClientAuthToken(key, secret string) ClientAuthenticator {
|
|
|
|
return &ClientAuthToken{
|
|
|
|
key: key,
|
|
|
|
secret: secret,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *ClientAuthToken) getKey() string {
|
|
|
|
return c.key
|
|
|
|
}
|
|
|
|
func (c *ClientAuthToken) getSecret() string {
|
|
|
|
return c.secret
|
|
|
|
}
|
|
|
|
|
|
|
|
func New(auth ClientAuthenticator) *Client {
|
|
|
|
p := &Client{}
|
2021-01-31 07:41:23 +01:00
|
|
|
return p
|
|
|
|
}
|
2021-01-31 09:08:52 +01:00
|
|
|
|
|
|
|
func (c *Client) V1() *api.V1Client {
|
|
|
|
return c.v1client
|
|
|
|
}
|