/
tree_query.go
216 lines (167 loc) · 5.77 KB
/
tree_query.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
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// TreeQuery Search Queries
//
// swagger:model treeQuery
type TreeQuery struct {
// Search in textual content (if search engine has this feature enabled)
Content string `json:"Content,omitempty"`
// Compute MinDate/MaxDate with a Golang duration with a leading comparator (> or <)
// Duration may contain "s" second, "m" minute, "d" day.
// Example: ">10m" for files modified before 10minutes ago
DurationDate string `json:"DurationDate,omitempty"`
// Look for a specific ETag value, may only be useful to lookup for files with __temporary__ ETag
ETag string `json:"ETag,omitempty"`
// Search files by their extension, use pipe symbol | if you wish to allow many extensions.
// Example png|pdf|jpg
Extension string `json:"Extension,omitempty"`
// Lookup by file basename
FileName string `json:"FileName,omitempty"`
// Search in either filename or content (if search engine has this feature enabled)
FileNameOrContent string `json:"FileNameOrContent,omitempty"`
// Bleve-like search query to search for a specific metadata value.
// When querying nodes, this will redirect this query to the Search Engine. When filtering an input, this will load an in-memory bleve engine to evaluate the node.
//
// Bleve query string format is a space separated list of `[+-]key:value`, where node meta keys must be prepended with "Meta."
// For Example, for tags: `+Meta.usermeta-tags:myvalue`
FreeString string `json:"FreeString,omitempty"`
// Search geographically
GeoQuery *TreeGeoQuery `json:"GeoQuery,omitempty"`
// Range for modification date - node was modified before this date
MaxDate string `json:"MaxDate,omitempty"`
// Range for file size - size is smaller than
MaxSize string `json:"MaxSize,omitempty"`
// Range for modification date - node was modified after this date
MinDate string `json:"MinDate,omitempty"`
// Range for file size - size bigger than
MinSize string `json:"MinSize,omitempty"`
// Negate this query
Not bool `json:"Not,omitempty"`
// Restrict recursive listing to a given level of the tree starting from root.
// Special value "-1" should list only one level in the folder defined by PathPrefix
PathDepth int32 `json:"PathDepth,omitempty"`
// Recursive listing of nodes below a given path. Combine with the PathDepth parameter to limit request results
PathPrefix []string `json:"PathPrefix"`
// List of nodes paths, exactly matching
Paths []string `json:"Paths"`
// Limit to a given node type (file or folder)
Type *TreeNodeType `json:"Type,omitempty"`
// Preset list of specific node defined by their UUIDs
UUIDs []string `json:"UUIDs"`
}
// Validate validates this tree query
func (m *TreeQuery) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateGeoQuery(formats); err != nil {
res = append(res, err)
}
if err := m.validateType(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *TreeQuery) validateGeoQuery(formats strfmt.Registry) error {
if swag.IsZero(m.GeoQuery) { // not required
return nil
}
if m.GeoQuery != nil {
if err := m.GeoQuery.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("GeoQuery")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("GeoQuery")
}
return err
}
}
return nil
}
func (m *TreeQuery) validateType(formats strfmt.Registry) error {
if swag.IsZero(m.Type) { // not required
return nil
}
if m.Type != nil {
if err := m.Type.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("Type")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("Type")
}
return err
}
}
return nil
}
// ContextValidate validate this tree query based on the context it is used
func (m *TreeQuery) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
var res []error
if err := m.contextValidateGeoQuery(ctx, formats); err != nil {
res = append(res, err)
}
if err := m.contextValidateType(ctx, formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *TreeQuery) contextValidateGeoQuery(ctx context.Context, formats strfmt.Registry) error {
if m.GeoQuery != nil {
if swag.IsZero(m.GeoQuery) { // not required
return nil
}
if err := m.GeoQuery.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("GeoQuery")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("GeoQuery")
}
return err
}
}
return nil
}
func (m *TreeQuery) contextValidateType(ctx context.Context, formats strfmt.Registry) error {
if m.Type != nil {
if swag.IsZero(m.Type) { // not required
return nil
}
if err := m.Type.ContextValidate(ctx, formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("Type")
} else if ce, ok := err.(*errors.CompositeError); ok {
return ce.ValidateName("Type")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *TreeQuery) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *TreeQuery) UnmarshalBinary(b []byte) error {
var res TreeQuery
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}