/
root.go
186 lines (132 loc) · 3.83 KB
/
root.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
// Code generated by elegen. DO NOT EDIT.
// Source: go.aporeto.io/elemental (templates/model.gotpl)
package testmodel
import (
"fmt"
"github.com/globalsign/mgo/bson"
"github.com/mitchellh/copystructure"
"go.aporeto.io/elemental"
)
// RootIdentity represents the Identity of the object.
var RootIdentity = elemental.Identity{
Name: "root",
Category: "root",
Package: "todo-list",
Private: false,
}
// Root represents the model of a root
type Root struct {
ModelVersion int `json:"-" msgpack:"-" bson:"_modelversion"`
}
// NewRoot returns a new *Root
func NewRoot() *Root {
return &Root{
ModelVersion: 1,
}
}
// Identity returns the Identity of the object.
func (o *Root) Identity() elemental.Identity {
return RootIdentity
}
// Identifier returns the value of the object's unique identifier.
func (o *Root) Identifier() string {
return ""
}
// SetIdentifier sets the value of the object's unique identifier.
func (o *Root) SetIdentifier(id string) {
}
// GetBSON implements the bson marshaling interface.
// This is used to transparently convert ID to MongoDBID as ObectID.
func (o *Root) GetBSON() (any, error) {
if o == nil {
return nil, nil
}
s := &mongoAttributesRoot{}
return s, nil
}
// SetBSON implements the bson marshaling interface.
// This is used to transparently convert ID to MongoDBID as ObectID.
func (o *Root) SetBSON(raw bson.Raw) error {
if o == nil {
return nil
}
s := &mongoAttributesRoot{}
if err := raw.Unmarshal(s); err != nil {
return err
}
return nil
}
// Version returns the hardcoded version of the model.
func (o *Root) Version() int {
return 1
}
// BleveType implements the bleve.Classifier Interface.
func (o *Root) BleveType() string {
return "root"
}
// DefaultOrder returns the list of default ordering fields.
func (o *Root) DefaultOrder() []string {
return []string{}
}
// Doc returns the documentation for the object
func (o *Root) Doc() string {
return `Root object of the API.`
}
func (o *Root) String() string {
return fmt.Sprintf("<%s:%s>", o.Identity().Name, o.Identifier())
}
// DeepCopy returns a deep copy if the Root.
func (o *Root) DeepCopy() *Root {
if o == nil {
return nil
}
out := &Root{}
o.DeepCopyInto(out)
return out
}
// DeepCopyInto copies the receiver into the given *Root.
func (o *Root) DeepCopyInto(out *Root) {
target, err := copystructure.Copy(o)
if err != nil {
panic(fmt.Sprintf("Unable to deepcopy Root: %s", err))
}
*out = *target.(*Root)
}
// Validate valides the current information stored into the structure.
func (o *Root) Validate() error {
errors := elemental.Errors{}
requiredErrors := elemental.Errors{}
if len(requiredErrors) > 0 {
return requiredErrors
}
if len(errors) > 0 {
return errors
}
return nil
}
// SpecificationForAttribute returns the AttributeSpecification for the given attribute name key.
func (*Root) SpecificationForAttribute(name string) elemental.AttributeSpecification {
if v, ok := RootAttributesMap[name]; ok {
return v
}
// We could not find it, so let's check on the lower case indexed spec map
return RootLowerCaseAttributesMap[name]
}
// AttributeSpecifications returns the full attribute specifications map.
func (*Root) AttributeSpecifications() map[string]elemental.AttributeSpecification {
return RootAttributesMap
}
// ValueForAttribute returns the value for the given attribute.
// This is a very advanced function that you should not need but in some
// very specific use cases.
func (o *Root) ValueForAttribute(name string) any {
switch name {
}
return nil
}
// RootAttributesMap represents the map of attribute for Root.
var RootAttributesMap = map[string]elemental.AttributeSpecification{}
// RootLowerCaseAttributesMap represents the map of attribute for Root.
var RootLowerCaseAttributesMap = map[string]elemental.AttributeSpecification{}
type mongoAttributesRoot struct {
}