forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ioconnectivityloscapabilities.go
139 lines (116 loc) · 4.31 KB
/
ioconnectivityloscapabilities.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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package swordfish
import (
"encoding/json"
"reflect"
"github.com/stmcginnis/gofish/common"
)
// IOConnectivityLoSCapabilities describes capabilities of the system to
// support various IO Connectivity service options.
type IOConnectivityLoSCapabilities struct {
common.Entity
// ODataContext is the odata context.
ODataContext string `json:"@odata.context"`
// ODataType is the odata type.
ODataType string `json:"@odata.type"`
// Description provides a description of this resource.
Description string
// Identifier shall be unique within the managed ecosystem.
Identifier common.Identifier
// MaxSupportedBytesPerSecond shall be the maximum bytes per second that a
// connection can support.
MaxSupportedBytesPerSecond int64
// MaxSupportedIOPS shall be the maximum IOPS that a connection can support.
MaxSupportedIOPS int
// SupportedAccessProtocols is Access protocols supported by this service
// option. NOTE: SMB+NFS* requires that SMB and at least one of NFSv3 or
// NFXv4 are also selected, (i.e. {'SMB', 'NFSv4', 'SMB+NFS*'}).
SupportedAccessProtocols []common.Protocol
// SupportedLinesOfService shall contain known and
// supported IOConnectivityLinesOfService.
SupportedLinesOfService []IOConnectivityLineOfService
// SupportedLinesOfServiceCount is the number of IOConnectivityLineOfServices.
SupportedLinesOfServiceCount int `json:"SupportedLinesOfService@odata.count"`
// rawData holds the original serialized JSON so we can compare updates.
rawData []byte
}
// UnmarshalJSON unmarshals a IOConnectivityLoSCapabilities object from the raw JSON.
func (ioconnectivityloscapabilities *IOConnectivityLoSCapabilities) UnmarshalJSON(b []byte) error {
type temp IOConnectivityLoSCapabilities
var t struct {
temp
}
err := json.Unmarshal(b, &t)
if err != nil {
return err
}
*ioconnectivityloscapabilities = IOConnectivityLoSCapabilities(t.temp)
// Extract the links to other entities for later
// This is a read/write object, so we need to save the raw object data for later
ioconnectivityloscapabilities.rawData = b
return nil
}
// Update commits updates to this object's properties to the running system.
func (ioconnectivityloscapabilities *IOConnectivityLoSCapabilities) Update() error {
// Get a representation of the object's original state so we can find what
// to update.
original := new(IOConnectivityLoSCapabilities)
err := original.UnmarshalJSON(ioconnectivityloscapabilities.rawData)
if err != nil {
return err
}
readWriteFields := []string{
"MaxSupportedBytesPerSecond",
"MaxSupportedIOPS",
"SupportedAccessProtocols",
"SupportedLinesOfService",
}
originalElement := reflect.ValueOf(original).Elem()
currentElement := reflect.ValueOf(ioconnectivityloscapabilities).Elem()
return ioconnectivityloscapabilities.Entity.Update(originalElement, currentElement, readWriteFields)
}
// GetIOConnectivityLoSCapabilities will get a IOConnectivityLoSCapabilities
// instance from the service.
func GetIOConnectivityLoSCapabilities(c common.Client, uri string) (*IOConnectivityLoSCapabilities, error) {
var ioConnectivityLoSCapabilities IOConnectivityLoSCapabilities
return &ioConnectivityLoSCapabilities, ioConnectivityLoSCapabilities.Get(c, uri, &ioConnectivityLoSCapabilities)
}
// ListReferencedIOConnectivityLoSCapabilitiess gets the collection of
// IOConnectivityLoSCapabilities from a provided reference.
func ListReferencedIOConnectivityLoSCapabilitiess(c common.Client, link string) ([]*IOConnectivityLoSCapabilities, error) { //nolint:dupl
var result []*IOConnectivityLoSCapabilities
if link == "" {
return result, nil
}
type GetResult struct {
Item *IOConnectivityLoSCapabilities
Link string
Error error
}
ch := make(chan GetResult)
collectionError := common.NewCollectionError()
get := func(link string) {
ioconnectivityloscapabilities, err := GetIOConnectivityLoSCapabilities(c, link)
ch <- GetResult{Item: ioconnectivityloscapabilities, Link: link, Error: err}
}
go func() {
err := common.CollectList(get, c, link)
if err != nil {
collectionError.Failures[link] = err
}
close(ch)
}()
for r := range ch {
if r.Error != nil {
collectionError.Failures[r.Link] = r.Error
} else {
result = append(result, r.Item)
}
}
if collectionError.Empty() {
return result, nil
}
return result, collectionError
}