forked from rexray/rexray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types_clients.go
206 lines (164 loc) · 5.46 KB
/
types_clients.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
package types
import (
"strings"
)
// ClientType is a client's type.
type ClientType int
const (
// UnknownClientType is an unknown client type.
UnknownClientType ClientType = iota
// IntegrationClient is the default client type -- a client that both
// communicates with a remote libStorage endpoint as well as interacts with
// the local host.
IntegrationClient
// ControllerClient is a libStorage client that has no interaction with
// the local host, removing any need for access to libStorage executors.
ControllerClient
)
// String returns the client type's string representation.
func (t ClientType) String() string {
switch t {
case IntegrationClient:
return "integration"
case ControllerClient:
return "controller"
default:
return ""
}
}
// ParseClientType parses a new client type.
func ParseClientType(str string) ClientType {
str = strings.ToLower(str)
switch str {
case "integration":
return IntegrationClient
case "controller":
return ControllerClient
}
return UnknownClientType
}
// Client is the libStorage client.
type Client interface {
// API returns the underlying libStorage API client.
API() APIClient
// OS returns the client's OS driver instance.
OS() OSDriver
// Storage returns the client's storage driver instance.
Storage() StorageDriver
// IntegrationDriver returns the client's integration driver instance.
Integration() IntegrationDriver
// Executor returns the storage executor CLI.
Executor() StorageExecutorCLI
}
// ProvidesAPIClient is any type that provides the API client.
type ProvidesAPIClient interface {
// API provides the API client.
API() APIClient
}
// APIClient is the libStorage API client used for communicating with a remote
// libStorage endpoint.
type APIClient interface {
// ServerName returns the name of the server to which the client is
// connected. This is not the same as the host name, rather it's the
// randomly generated name the server creates for unique identification
// when the server starts for the first time.
ServerName() string
// LogRequests enables or disables the logging of client HTTP requests.
LogRequests(enabled bool)
// LogResponses enables or disables the logging of client HTTP responses.
LogResponses(enabled bool)
// Root returns a list of root resources.
Root(ctx Context) ([]string, error)
// Instances returns a list of instances.
Instances(ctx Context) (map[string]*Instance, error)
// InstanceInspect inspects an instance.
InstanceInspect(ctx Context, service string) (*Instance, error)
// Services returns a map of the configured Services.
Services(ctx Context) (map[string]*ServiceInfo, error)
// ServiceInspect returns information about a service.
ServiceInspect(ctx Context, name string) (*ServiceInfo, error)
// Volumes returns a list of all Volumes for all Services.
Volumes(
ctx Context,
attachments VolumeAttachmentsTypes) (ServiceVolumeMap, error)
// VolumesByService returns a list of all Volumes for a service.
VolumesByService(
ctx Context,
service string,
attachments VolumeAttachmentsTypes) (VolumeMap, error)
// VolumeInspect gets information about a single volume by ID.
VolumeInspect(
ctx Context,
service, volumeID string,
attachments VolumeAttachmentsTypes) (*Volume, error)
// VolumeInspectByName gets information about a single volume by name.
VolumeInspectByName(
ctx Context,
service, volumeName string,
attachments VolumeAttachmentsTypes) (*Volume, error)
// VolumeCreate creates a single volume.
VolumeCreate(
ctx Context,
service string,
request *VolumeCreateRequest) (*Volume, error)
// VolumeCreateFromSnapshot creates a single volume from a snapshot.
VolumeCreateFromSnapshot(
ctx Context,
service, snapshotID string,
request *VolumeCreateRequest) (*Volume, error)
// VolumeCopy copies a single volume.
VolumeCopy(
ctx Context,
service, volumeID string,
request *VolumeCopyRequest) (*Volume, error)
// VolumeRemove removes a single volume.
VolumeRemove(
ctx Context,
service, volumeID string,
force bool) error
// VolumeAttach attaches a single volume.
VolumeAttach(
ctx Context,
service string,
volumeID string,
request *VolumeAttachRequest) (*Volume, string, error)
// VolumeDetach attaches a single volume.
VolumeDetach(
ctx Context,
service string,
volumeID string,
request *VolumeDetachRequest) (*Volume, error)
// VolumeDetachAll attaches all volumes from all
VolumeDetachAll(
ctx Context,
request *VolumeDetachRequest) (ServiceVolumeMap, error)
// VolumeDetachAllForService detaches all volumes from a service.
VolumeDetachAllForService(
ctx Context,
service string,
request *VolumeDetachRequest) (VolumeMap, error)
// VolumeSnapshot creates a single snapshot.
VolumeSnapshot(
ctx Context,
service string,
volumeID string,
request *VolumeSnapshotRequest) (*Snapshot, error)
// Snapshots returns a list of all Snapshots for all
Snapshots(ctx Context) (ServiceSnapshotMap, error)
// SnapshotsByService returns a list of all Snapshots for a single service.
SnapshotsByService(
ctx Context, service string) (SnapshotMap, error)
// SnapshotInspect gets information about a single snapshot.
SnapshotInspect(
ctx Context,
service, snapshotID string) (*Snapshot, error)
// SnapshotRemove removes a single snapshot.
SnapshotRemove(
ctx Context,
service, snapshotID string) error
// SnapshotCopy copies a snapshot to a new snapshot.
SnapshotCopy(
ctx Context,
service, snapshotID string,
request *SnapshotCopyRequest) (*Snapshot, error)
}