-
Notifications
You must be signed in to change notification settings - Fork 50
/
options.go
61 lines (51 loc) · 1.12 KB
/
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
52
53
54
55
56
57
58
59
60
61
package proxmox
import (
"fmt"
"net/http"
)
type Option func(*Client)
// Deprecated: Use WithHTTPClient
func WithClient(client *http.Client) Option {
return WithHTTPClient(client)
}
func WithHTTPClient(client *http.Client) Option {
return func(c *Client) {
c.httpClient = client
}
}
// Deprecated: Use WithCredential
func WithLogins(username, password string) Option {
return WithCredentials(&Credentials{
Username: username,
Password: password,
})
}
func WithCredentials(credentials *Credentials) Option {
return func(c *Client) {
c.credentials = credentials
}
}
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
}
}