forked from oVirt/go-ovirt-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.go
64 lines (53 loc) · 1.38 KB
/
client.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
package ovirtclient
import (
"math/rand"
"net/http"
ovirtsdk4 "github.com/ovirt/go-ovirt"
)
// Client is a simplified client for the oVirt API.
//
//goland:noinspection GoDeprecation
type Client interface {
// GetURL returns the oVirt engine base URL.
GetURL() string
DiskClient
DiskAttachmentClient
VMClient
NICClient
VNICProfileClient
NetworkClient
DatacenterClient
ClusterClient
StorageDomainClient
HostClient
TemplateClient
TemplateDiskClient
TestConnectionClient
TagClient
}
// ClientWithLegacySupport is an extension of Client that also offers the ability to retrieve the underlying
// SDK connection or a configured HTTP client.
type ClientWithLegacySupport interface {
// GetSDKClient returns a configured oVirt SDK client for the use cases that are not covered by goVirt.
GetSDKClient() *ovirtsdk4.Connection
// GetHTTPClient returns a configured HTTP client for the oVirt engine. This can be used to send manual
// HTTP requests to the oVirt engine.
GetHTTPClient() http.Client
Client
}
type oVirtClient struct {
conn *ovirtsdk4.Connection
httpClient http.Client
logger Logger
url string
nonSecureRandom *rand.Rand
}
func (o *oVirtClient) GetSDKClient() *ovirtsdk4.Connection {
return o.conn
}
func (o *oVirtClient) GetHTTPClient() http.Client {
return o.httpClient
}
func (o *oVirtClient) GetURL() string {
return o.url
}