...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package models
20
21
22
23
24 import (
25 "context"
26 "strconv"
27
28 "github.com/go-openapi/errors"
29 "github.com/go-openapi/strfmt"
30 "github.com/go-openapi/swag"
31 "github.com/go-openapi/validate"
32 )
33
34
35
36
37 type LogInfo struct {
38
39
40 InactiveShards []*InactiveShardLogInfo `json:"inactiveShards"`
41
42
43
44
45 RootHash *string `json:"rootHash"`
46
47
48
49 SignedTreeHead *string `json:"signedTreeHead"`
50
51
52
53
54 TreeID *string `json:"treeID"`
55
56
57
58
59 TreeSize *int64 `json:"treeSize"`
60 }
61
62
63 func (m *LogInfo) Validate(formats strfmt.Registry) error {
64 var res []error
65
66 if err := m.validateInactiveShards(formats); err != nil {
67 res = append(res, err)
68 }
69
70 if err := m.validateRootHash(formats); err != nil {
71 res = append(res, err)
72 }
73
74 if err := m.validateSignedTreeHead(formats); err != nil {
75 res = append(res, err)
76 }
77
78 if err := m.validateTreeID(formats); err != nil {
79 res = append(res, err)
80 }
81
82 if err := m.validateTreeSize(formats); err != nil {
83 res = append(res, err)
84 }
85
86 if len(res) > 0 {
87 return errors.CompositeValidationError(res...)
88 }
89 return nil
90 }
91
92 func (m *LogInfo) validateInactiveShards(formats strfmt.Registry) error {
93 if swag.IsZero(m.InactiveShards) {
94 return nil
95 }
96
97 for i := 0; i < len(m.InactiveShards); i++ {
98 if swag.IsZero(m.InactiveShards[i]) {
99 continue
100 }
101
102 if m.InactiveShards[i] != nil {
103 if err := m.InactiveShards[i].Validate(formats); err != nil {
104 if ve, ok := err.(*errors.Validation); ok {
105 return ve.ValidateName("inactiveShards" + "." + strconv.Itoa(i))
106 } else if ce, ok := err.(*errors.CompositeError); ok {
107 return ce.ValidateName("inactiveShards" + "." + strconv.Itoa(i))
108 }
109 return err
110 }
111 }
112
113 }
114
115 return nil
116 }
117
118 func (m *LogInfo) validateRootHash(formats strfmt.Registry) error {
119
120 if err := validate.Required("rootHash", "body", m.RootHash); err != nil {
121 return err
122 }
123
124 if err := validate.Pattern("rootHash", "body", *m.RootHash, `^[0-9a-fA-F]{64}$`); err != nil {
125 return err
126 }
127
128 return nil
129 }
130
131 func (m *LogInfo) validateSignedTreeHead(formats strfmt.Registry) error {
132
133 if err := validate.Required("signedTreeHead", "body", m.SignedTreeHead); err != nil {
134 return err
135 }
136
137 return nil
138 }
139
140 func (m *LogInfo) validateTreeID(formats strfmt.Registry) error {
141
142 if err := validate.Required("treeID", "body", m.TreeID); err != nil {
143 return err
144 }
145
146 if err := validate.Pattern("treeID", "body", *m.TreeID, `^[0-9]+$`); err != nil {
147 return err
148 }
149
150 return nil
151 }
152
153 func (m *LogInfo) validateTreeSize(formats strfmt.Registry) error {
154
155 if err := validate.Required("treeSize", "body", m.TreeSize); err != nil {
156 return err
157 }
158
159 if err := validate.MinimumInt("treeSize", "body", *m.TreeSize, 1, false); err != nil {
160 return err
161 }
162
163 return nil
164 }
165
166
167 func (m *LogInfo) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
168 var res []error
169
170 if err := m.contextValidateInactiveShards(ctx, formats); err != nil {
171 res = append(res, err)
172 }
173
174 if len(res) > 0 {
175 return errors.CompositeValidationError(res...)
176 }
177 return nil
178 }
179
180 func (m *LogInfo) contextValidateInactiveShards(ctx context.Context, formats strfmt.Registry) error {
181
182 for i := 0; i < len(m.InactiveShards); i++ {
183
184 if m.InactiveShards[i] != nil {
185
186 if swag.IsZero(m.InactiveShards[i]) {
187 return nil
188 }
189
190 if err := m.InactiveShards[i].ContextValidate(ctx, formats); err != nil {
191 if ve, ok := err.(*errors.Validation); ok {
192 return ve.ValidateName("inactiveShards" + "." + strconv.Itoa(i))
193 } else if ce, ok := err.(*errors.CompositeError); ok {
194 return ce.ValidateName("inactiveShards" + "." + strconv.Itoa(i))
195 }
196 return err
197 }
198 }
199
200 }
201
202 return nil
203 }
204
205
206 func (m *LogInfo) MarshalBinary() ([]byte, error) {
207 if m == nil {
208 return nil, nil
209 }
210 return swag.WriteJSON(m)
211 }
212
213
214 func (m *LogInfo) UnmarshalBinary(b []byte) error {
215 var res LogInfo
216 if err := swag.ReadJSON(b, &res); err != nil {
217 return err
218 }
219 *m = res
220 return nil
221 }
222
View as plain text