Adding sample auth code that will most likely change and api implementation
Signed-off-by: Kris Nóva <kris@nivenly.com>
This commit is contained in:
parent
ef15a0ac15
commit
95794522e0
7 changed files with 279 additions and 278 deletions
65
client.go
65
client.go
|
@ -1,10 +1,65 @@
|
|||
package photoprism_client_go
|
||||
package photoprism
|
||||
|
||||
type PhotoprismClient struct {
|
||||
//
|
||||
import "github.com/kris-nova/client-go/api/v1"
|
||||
|
||||
type Client struct {
|
||||
v1client *api.V1Client
|
||||
}
|
||||
|
||||
func New() *PhotoprismClient {
|
||||
p := &PhotoprismClient{}
|
||||
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
|
||||
}
|
||||
|
||||
// -- [ 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{}
|
||||
return p
|
||||
}
|
||||
|
||||
func (c *Client) V1() *api.V1Client {
|
||||
return c.v1client
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue