forked from luthermonson/go-proxmox
/
options.go
51 lines (43 loc) · 897 Bytes
/
options.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package proxmox
import (
"fmt"
"net/http"
)
type Option func(*Client)
func WithClient(client *http.Client) Option {
return func(c *Client) {
c.httpClient = client
}
}
func WithLogins(username, password string) Option {
return func(c *Client) {
c.credentials = &Credentials{
Username: username,
Password: password,
}
}
}
func WithAPIToken(tokenID, secret string) Option {
return func(c *Client) {
c.token = fmt.Sprintf("%s=%s", tokenID, secret)
}
}
// WithSession experimental
func WithSession(ticket, csrfPreventionToken string) Option {
return func(c *Client) {
c.session = &Session{
Ticket: ticket,
CsrfPreventionToken: csrfPreventionToken,
}
}
}
func WithUserAgent(ua string) Option {
return func(c *Client) {
c.userAgent = ua
}
}
func WithLogger(logger LeveledLoggerInterface) Option {
return func(c *Client) {
c.log = logger
}
}