forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattributeregistry.go
310 lines (283 loc) · 11.6 KB
/
attributeregistry.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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
//
// SPDX-License-Identifier: BSD-3-Clause
//
package redfish
import (
"encoding/json"
"math/big"
"github.com/stmcginnis/gofish/common"
)
type AttributeType string
const (
// A flag with a true or false value.
BooleanAttributeType AttributeType = "Boolean"
// A list of the known possible enumerated values.
EnumerationAttributeType AttributeType = "Enumeration"
// An integer value.
IntegerAttributeType AttributeType = "Integer"
// Password values that do not appear as plain text.
// The value shall be null in responses.
PasswordAttributeType AttributeType = "Password"
// Free-form text in their values.
StringAttributeType AttributeType = "String"
)
// AttributeValue represents the possible values for enumerated attribute values.
type AttributeValue struct {
// A user-readable display string of the value for the attribute in the defined language.
ValueDisplayName string
// The unique value name for the attribute.
ValueName string
}
// Attribute represents attributes and their possible values in the attribute registry.
type Attribute struct {
// The unique name for the attribute.
AttributeName string
// The placeholder of the current value for the attribute.
CurrentValue interface{}
// The default value for the attribute.
DefaultValue interface{}
// The user-readable display string for the attribute
// in the defined language.
DisplayName string
// The ascending order, as a number, in which this attribute appears
// relative to other attributes.
DisplayOrder int64
// An indication of whether this attribute is grayed out.
GrayOut bool
// The help text for the attribute.
HelpText string
// An indication of whether this attribute is hidden in user interfaces.
Hidden bool
// An indication of whether this attribute is immutable.
Immutable bool
// An indication of whether this attribute is unique for this system
// and should not be replicated.
IsSystemUniqueProperty bool
// The lower limit for an integer attribute.
LowerBound int64
// The maximum character length of a string attribute.
MaxLength int64
// The path that describes the menu hierarchy of this attribute.
MenuPath string
// The minimum character length of the string attribute.
MinLength int64
// Oem contains all the vendor specific information.
Oem json.RawMessage
// An indication of whether this attribute is read-only.
ReadOnly bool
// An indication of whether a system or device reset is required
// for this attribute value change to take effect.
ResetRequired bool
// The amount to increment or decrement an integer attribute
// each time a user requests a value change.
ScalarIncrement int64
// The attribute type.
Type AttributeType
// The UEFI device path that qualifies this attribute.
UefiDevicePath string
// The UEFI keyword string for this attribute.
UefiKeywordName string
// The UEFI namespace ID for the attribute.
UefiNamespaceID string `json:"UefiNamespaceId"`
// The upper limit for an integer attribute.
UpperBound big.Int
// An array of the possible values for enumerated attribute values.
Value []AttributeValue
// A valid regular expression, according to the Perl regular expression dialect,
// that validates the attribute value.
ValueExpression string
// The warning text for the attribute.
WarningText string
// An indication of whether this attribute is write-only.
WriteOnly bool
}
type DependencyType string
const (
// A simple mapping dependency. If the condition evaluates to true,
// the attribute or state changes to the mapped value.
MapDependencyType DependencyType = "Map"
)
type MapToProperty string
const (
// The dependency that affects an attribute's CurrentValue.
CurrentValueMapToProperty MapToProperty = "CurrentValue"
// The dependency that affects an attribute's DefaultValue.
DefaultValueMapToProperty MapToProperty = "DefaultValue"
// The dependency that affects an attribute's DisplayName.
DisplayNameMapToProperty MapToProperty = "DisplayName"
// The dependency that affects an attribute's DisplayName.
DisplayOrderMapToProperty MapToProperty = "DisplayOrder"
// The dependency that affects an attribute's GrayOut state.
GrayOutMapToProperty MapToProperty = "GrayOut"
// The dependency that affects an attribute's HelpText.
HelpTextMapToProperty MapToProperty = "HelpText"
// The dependency that affects an attribute's Hidden state.
HiddenMapToProperty MapToProperty = "Hidden"
// The dependency that affects an attribute's Immutable state.
ImmutableMapToProperty MapToProperty = "Immutable"
// The dependency that affects an attribute's LowerBound.
LowerBoundMapToProperty MapToProperty = "LowerBound"
// The dependency that affects an attribute's MaxLength.
MaxLengthMapToProperty MapToProperty = "MaxLength"
// The dependency that affects an attribute's MinLength.
MinLengthMapToProperty MapToProperty = "MinLength"
// The dependency that affects an attribute's ReadOnly state.
ReadOnlyMapToProperty MapToProperty = "ReadOnly"
// The dependency that affects an attribute's ScalarIncrement.
ScalarIncrementMapToProperty MapToProperty = "ScalarIncrement"
// The dependency that affects an attribute's UpperBound.
UpperBoundMapToProperty MapToProperty = "UpperBound"
// The dependency that affects an attribute's ValueExpression.
ValueExpressionMapToProperty MapToProperty = "ValueExpression"
// The dependency that affects an attribute's WarningText.
WarningTextMapToProperty MapToProperty = "WarningText"
// The dependency that affects an attribute's WriteOnly state.
WriteOnlyMapToProperty MapToProperty = "WriteOnly"
)
type MapFromProperty string
const (
// The dependency on an attribute's CurrentValue
CurrentValueMapFromProperty MapFromProperty = "CurrentValue"
// The dependency on an attribute's DefaultValue.
DefaultValueMapFromProperty MapFromProperty = "DefaultValue"
// The dependency on an attribute's GrayOut state.
GrayOutMapFromProperty MapFromProperty = "GrayOut"
// The dependency on an attribute's Hidden state.
HiddenMapFromProperty MapFromProperty = "Hidden"
// The dependency on an attribute's LowerBound.
LowerBoundMapFromProperty MapFromProperty = "LowerBound"
// The dependency on an attribute's MaxLength.
MaxLengthMapFromProperty MapFromProperty = "MaxLength"
// The dependency on an attribute's MinLength.
MinLengthMapFromProperty MapFromProperty = "MinLength"
// The dependency on an attribute's ReadOnly state.
ReadOnlyMapFromProperty MapFromProperty = "ReadOnly"
// The dependency on an attribute's ScalarIncrement.
ScalarIncrementMapFromProperty MapFromProperty = "ScalarIncrement"
// The dependency on an attribute's UpperBound.
UpperBoundMapFromProperty MapFromProperty = "UpperBound"
// The dependency on an attribute's WriteOnly state.
WriteOnlyMapFromProperty MapFromProperty = "WriteOnly"
)
type MapFromCondition string
const (
// The logical operation for 'Equal'.
EqualCondition MapFromCondition = "EQU"
// The logical operation for 'Greater than or Equal'.
GreaterThanOrEqualCondition MapFromCondition = "GEQ"
// The logical operation for 'Greater than'.
GreaterThanCondition MapFromCondition = "GTR"
// The logical operation for 'Less than or Equal'.
LessThanOrEqualCondition MapFromCondition = "LEQ"
// The logical operation for 'Less than'.
LessThanCondition MapFromCondition = "LSS"
// The logical operation for 'Not Equal'.
NotEqualCondition MapFromCondition = "NEQ"
)
type MapTerms string
const (
// The operation used for logical 'AND' of dependency terms.
AndLogicalTerm MapTerms = "AND"
// The operation used for logical 'OR' of dependency terms.
OrLogicalTerm MapTerms = "OR"
)
type MapFrom struct {
// The attribute to use to evaluate this dependency expression.
MapFromAttribute string
// The condition to use to evaluate this dependency expression.
MapFromCondition MapFromCondition
// The metadata property for the attribute that the MapFromAttribute property specifies
// to use to evaluate this dependency expression.
MapFromProperty MapFromProperty
// The value to use to evaluate this dependency expression.
MapFromValue interface{}
// The logical term that combines two or more map-from conditions
// in this dependency expression.
MapTerms MapTerms
}
// The dependency expression for one or more attributes in this attribute registry.
type DependencyExpression struct {
// An array of the map-from conditions for a mapping dependency.
MapFrom []MapFrom
// The AttributeName of the attribute that is affected by this dependency expression.
MapToAttribute string
// The metadata property for the attribute that contains
// the map-from condition that evaluates this dependency expression.
MapToProperty MapToProperty
// The value that the map-to property changes to
// if the dependency expression evaluates to true.
MapToValue interface{}
}
// Dependency represents dependencies of attributes on this component.
type Dependency struct {
// The dependency expression for one or more attributes in this attribute registry.
Dependency DependencyExpression
// The AttributeName of the attribute whose change triggers
// the evaluation of this dependency expression.
DependencyFor string
// The type of the dependency structure.
Type DependencyType
}
// Menu represents the attributes menus and their hierarchy in the attribute registry.
type Menu struct {
// The user-readable display string of this menu in the defined language.
DisplayName string
// The ascending order, as a number, in which this menu appears relative to other menus.
DisplayOrder int64
// An indication of whether this menu is grayed out.
GrayOut bool
// An indication of whether this menu is hidden in user interfaces.
Hidden bool
// The unique name string of this menu.
MenuName string
// The path to the menu names that describes this menu
// hierarchy relative to other menus.
MenuPath string
// Oem contains all the vendor specific information.
Oem json.RawMessage
// An indication of whether this menu is read-only.
ReadOnly bool
}
// RegistryEntries shall list attributes for this component,
// along with their possible values, dependencies, and other metadata.
type RegistryEntries struct {
// An array of attributes and their possible values in the attribute registry.
Attributes []Attribute
// An array of dependencies of attributes on this component.
Dependencies []Dependency
// An array for the attributes menus and their hierarchy in the attribute registry.
Menus []Menu
}
type SupportedSystem struct {
// The version of the component firmware image to which this attribute registry applies.
FirmwareVersion string
// The product name of the computer system to which this attribute registry applies.
ProductName string
// The ID of the systems to which this attribute registry applies.
SystemID string `json:"SystemId"`
}
// AttributeRegistry shall represent an attribute registry for a Redfish implementation.
type AttributeRegistry 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
// The RFC5646-conformant language code for the attribute registry.
Language string
// The organization or company that publishes this attribute registry.
OwningEntity string
// The list of all attributes and their metadata for this component.
RegistryEntries RegistryEntries
// The attribute registry version.
RegistryVersion string
// An array of systems that this attribute registry supports.
SupportedSystems []SupportedSystem
}
// GetAttributeRegistry will get an AttributeRegistry instance from the Redfish service,
// e.g. BiosAttributeRegistry
func GetAttributeRegistry(c common.Client, uri string) (*AttributeRegistry, error) {
return common.GetObject[AttributeRegistry](c, uri)
}