forked from transip/gotransip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.go
71 lines (64 loc) · 3.01 KB
/
configuration.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
62
63
64
65
66
67
68
69
70
71
package gotransip
import (
"io"
"net/http"
"time"
"github.com/assi010/gotransip/v6/authenticator"
)
const (
libraryVersion = "6.17.0"
defaultBasePath = "https://api.transip.nl/v6"
userAgent = "go-client-gotransip/" + libraryVersion
)
// APIMode specifies in which mode the API is used. Currently this is only
// supports either readonly or readwrite
type APIMode string
var (
// APIModeReadOnly specifies that no changes can be made from API calls.
// If you do try to order a product or change some data, the api will return an error.
APIModeReadOnly APIMode = "readonly"
// APIModeReadWrite specifies that changes can be made from API calls
APIModeReadWrite APIMode = "readwrite"
)
// DemoClientConfiguration is the default configuration to use when testing the demo mode of the transip api.
// Demo mode allows users to test without authenticating with their own credentials.
var DemoClientConfiguration = ClientConfiguration{Token: authenticator.DemoToken}
// ClientConfiguration stores the configuration of the API client
type ClientConfiguration struct {
// AccountName is the name of the account of the user, this is used in combination with a private key.
// When requesting a new token, the account name will be part of the token request body
AccountName string
// URL is set by default to the transip api server
// this is mainly used in tests to point to a mock server
URL string
// PrivateKeyPath is the filesystem location to the private key
PrivateKeyPath string
// For users that want the possibility to store their key elsewhere,
// not on a filesystem but on X datastore
PrivateKeyReader io.Reader
// Token field gives users the option of providing their own acquired token,
// for example when generated in the transip control panel
Token string
// TestMode is used when users want to tinker with the api without touching their real data.
// So you can view your own data, order new products, but the actual order never happens.
TestMode bool
// optionally you can set your own HTTPClient
// to set extra non default settings
HTTPClient *http.Client
// APIMode specifies in which mode the API is used. Currently this is only
// supports either readonly or readwrite
Mode APIMode
// TokenCache is used to retrieve previously acquired tokens and saving new ones
// If not set we do not use a cache to store the new acquired tokens
TokenCache authenticator.TokenCache
// TokenExpiration defines the lifetime of new tokens requested by the authenticator.
// If unspecified, the default is 1 day.
// This has no effect for tokens provided via the Token field.
TokenExpiration time.Duration
// TokenWhitelisted is used to indicate only whitelisted IP's may use the new tokens requested by the authenticator.
// This has no effect for tokens provided via the Token field.
TokenWhitelisted bool
// A KeyManager is used to offload the signing of a new Token request to a third party (e.g. a key vault).
// This is meant as an alternative for providing a private key directly
KeyManager authenticator.KeyManager
}