-
Notifications
You must be signed in to change notification settings - Fork 21
/
instancetype.go
52 lines (40 loc) · 1.14 KB
/
instancetype.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
package ovirtclient
import ovirtsdk "github.com/ovirt/go-ovirt"
// InstanceTypeID is a type alias for instance type IDs.
type InstanceTypeID string
// InstanceTypeClient lists the methods for working with instance types.
type InstanceTypeClient interface {
GetInstanceType(id InstanceTypeID, retries ...RetryStrategy) (InstanceType, error)
ListInstanceTypes(retries ...RetryStrategy) ([]InstanceType, error)
}
// InstanceTypeData is the data segment of the InstanceType type.
type InstanceTypeData interface {
ID() InstanceTypeID
Name() string
}
// InstanceType is a data structure that contains preconfigured instance parameters.
type InstanceType interface {
InstanceTypeData
}
func convertSDKInstanceType(object *ovirtsdk.InstanceType, o *oVirtClient) (InstanceType, error) {
name, ok := object.Name()
if !ok {
return nil, newFieldNotFound("instance type", "name")
}
return &instanceType{
o,
InstanceTypeID(object.MustId()),
name,
}, nil
}
type instanceType struct {
client Client
id InstanceTypeID
name string
}
func (i instanceType) Name() string {
return i.name
}
func (i instanceType) ID() InstanceTypeID {
return i.id
}