/
list.go
305 lines (254 loc) · 10.8 KB
/
list.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
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package apis
type ScopedResourceInput struct {
// 指定查询的权限范围,可能值为project, domain or system
Scope string `json:"scope"`
}
type DomainizedResourceListInput struct {
// swagger:ignore
// Is an admin call? equivalent to scope=system
// Deprecated
Admin *bool `json:"admin"`
ScopedResourceInput
DomainizedResourceInput
// 对具有域属性的资源,严格匹配域ID
ProjectDomainIds []string `json:"project_domain_ids"`
// Deprecated
// swagger:ignore
ProjectDomains []string `json:"project_domains" yunion-deprecated-by:"project_domain_ids"`
// 按domain名称排序,可能值为asc|desc
// pattern: asc|desc
OrderByDomain string `json:"order_by_domain"`
}
type ProjectizedResourceListInput struct {
DomainizedResourceListInput
ProjectizedResourceInput
// 对具有项目属性的资源,严格匹配项目ID
ProjectIds []string `json:"project_ids"`
// Deprecated
// swagger:ignore
Projects []string `json:"projects" yunion-deprecated-by:"project_ids"`
// 按project名称排序,可能值为asc|desc
// pattern: asc|desc
OrderByProject string `json:"order_by_project"`
// swagger:ignore
// Deprecated
OrderByTenant string `json:"order_by_tenant" yunion-deprecated-by:"order_by_project"`
}
type StatusDomainLevelUserResourceListInput struct {
StatusDomainLevelResourceListInput
// 查询指定的用户(ID或名称)拥有的资源
UserId string `json:"user_id"`
// swagger:ignore
// Deprecated
// Filter by userId
User string `json:"user" yunion-deprecated-by:"user_id"`
}
type UserResourceListInput struct {
StandaloneResourceListInput
ScopedResourceInput
// swagger:ignore
// Is an admin call? equivalent to scope=system
// Deprecated
Admin *bool `json:"admin"`
// 查询指定的用户(ID或名称)拥有的资源
UserId string `json:"user_id"`
// swagger:ignore
// Deprecated
// Filter by userId
User string `json:"user" yunion-deprecated-by:"user_id"`
}
type ModelBaseListInput struct {
Meta
// 查询限制量
// default: 20
Limit *int `json:"limit" default:"20" help:"max items per page"`
// 查询偏移量
// default: 0
Offset *int `json:"offset"`
// 列表排序时,用于排序的字段的名称,该字段不提供时,则按默认字段排序。一般时按照资源的新建时间逆序排序。
OrderBy []string `json:"order_by"`
// 列表排序时的顺序,desc为从高到低,asc为从低到高。默认是按照资源的创建时间desc排序。
// example: desc|asc
Order string `json:"order"`
// 列表返回资源的更多详细信息。默认只显示基本字段,该字段为true则返回扩展字段信息。
Details *bool `json:"details"`
// 模糊搜索所有字段
Search string `json:"search"`
// 指定过滤条件,允许指定多个,每个条件的格式为"字段名称.操作符(匹配信息)",例如name字段等于test的过滤器为:name.equals('test')
// 支持的操作符如下:
//
// | 操作符 | 参数个数 | 举例 | 说明 |
// |---------------|----------|------------------------------------------------|-----------------------------|
// | in | > 0 | name.in("test", "good") | 在给定数组中 |
// | notin | > 0 | name.notin('test') | 不在给定数组中 |
// | between | 2 | created_at.between('2019-12-10', '2020-01-02') | 在两个值之间 |
// | ge | 1 | created_at.ge('2020-01-01') | 大于或等于给定值 |
// | gt | 1 | created_at.gt('2020-01-01') | 严格大于给定值 |
// | le | 1 | created_at.le('2020-01-01') | 小于或等于给定值 |
// | lt | 1 | sync_seconds.lt(900) | 严格大于给定值 |
// | like | > 0 | name.like('%test%') | sql字符串匹配任意一个字符串 |
// | contains | > 0 | name.contains('test') | 包含任意一个给定字符串 |
// | startswith | > 0 | name.startswith('test') | 以任意一个给定字符串开头 |
// | endswith | > 0 | name.endswith('test') | 以任意一个给定字符串结尾 |
// | equals | > 0 | name.equals('test') | 等于任意一个给定值 |
// | notequals | 1 | name.notequals('test') | 不等于给定值 |
// | isnull | 0 | name.isnull() | 值为SQL的NULL |
// | isnotnull | 0 | name.isnotnull() | 值不为SQL的NULL |
// | isempty | 0 | name.isempty('test') | 值为空字符串 |
// | isnotempty | 0 | name.isnotempty('test') | 值不是空字符串 |
// | isnullorempty | 0 | name.isnullorempty('test') | 值为SQL的NULL或者空字符串 |
//
Filter []string `json:"filter"`
// 指定关联过滤条件,允许指定多个,后端将根据关联过滤条件和其他表关联查询,支持的查询语法和filter相同,
// 和其他表关联的语法如下:
// joint_resources.related_key(origin_key).filter_col.filter_ops(values)
// 其中,joint_resources为要关联的资源名称,related_key为关联表column,origin_key为当前表column, filter_col为
// 关联表用于查询匹配的field名称,field_ops为filter支持的操作,values为匹配的值
// 举例:
// guestnetworks.guest_id(id).ip_addr.equals('10.168.21.222')
JointFilter []string `json:"joint_filter"`
// 如果filter_any为true,则查询所有filter的并集,否则为交集
FilterAny *bool `json:"filter_any"`
// 返回结果只包含指定的字段
Field []string `json:"field"`
// 用于数据导出,指定导出的数据字段
ExportKeys string `json:"export_keys"`
// 返回结果携带delete_fail_reason和update_fail_reason字段
ShowFailReason *bool `json:"show_fail_reason"`
}
type IncrementalListInput struct {
// 用于指定增量加载的标记
PagingMarker string `json:"paging_marker"`
}
type VirtualResourceListInput struct {
StatusStandaloneResourceListInput
ProjectizedResourceListInput
// 列表中包含标记为"系统资源"的资源
System *bool `json:"system"`
// 是否显示回收站内的资源,默认不显示(对实现了回收站的资源有效,例如主机,磁盘,镜像)
PendingDelete *bool `json:"pending_delete"`
// 是否显示所有资源,包括回收站和不再回收站的资源
// TODO: fix this???
PendingDeleteAll *bool `json:"-"`
}
type ResourceBaseListInput struct {
ModelBaseListInput
}
type SharableVirtualResourceListInput struct {
VirtualResourceListInput
SharableResourceBaseListInput
// 根据资源的共享范围过滤列表,可能值为:system, domain, project
PublicScope string `json:"public_scope"`
}
type AdminSharableVirtualResourceListInput struct {
SharableVirtualResourceListInput
}
type STag struct {
// 标签key
Key string
// 标签Value
Value string
}
type MetadataResourceListInput struct {
// 通过标签过滤
Tags []STag `json:"tags"`
// 通过标签过滤
OrderByTag string `json:"order_by_tag"`
// deprecated
// 返回资源的标签不包含用户标签
WithoutUserMeta *bool `json:"without_user_meta"`
// 返回资源的标签包含用户标签
WithUserMeta *bool `json:"with_user_meta"`
// 返回资源的标签包含外部标签
WithCloudMeta *bool `json:"with_cloud_meta"`
// 返回列表数据中包含资源的标签数据(Metadata)
WithMeta *bool `json:"with_meta"`
}
type StandaloneResourceListInput struct {
ResourceBaseListInput
MetadataResourceListInput
// 显示所有的资源,包括模拟的资源
ShowEmulated *bool `json:"show_emulated" help:"show emulated resources" negative:"do not show emulated resources"`
// 以资源名称过滤列表
Names []string `json:"name" help:"filter by names"`
// 以资源ID过滤列表
Ids []string `json:"id" help:"filter by ids"`
}
type StatusResourceBaseListInput struct {
// 以资源的状态过滤列表
Status []string `json:"status"`
}
type EnabledResourceBaseListInput struct {
// 以资源是否启用/禁用过滤列表
Enabled *bool `json:"enabled"`
}
type SharableResourceBaseListInput struct {
// 以资源是否共享过滤列表
IsPublic *bool `json:"is_public"`
// 根据资源的共享范围过滤列表,可能值为:system, domain, project
PublicScope string `json:"public_scope"`
}
type DomainLevelResourceListInput struct {
StandaloneResourceListInput
DomainizedResourceListInput
}
type StatusStandaloneResourceListInput struct {
StandaloneResourceListInput
StatusResourceBaseListInput
}
type EnabledStatusStandaloneResourceListInput struct {
StatusStandaloneResourceListInput
EnabledResourceBaseListInput
}
type StatusDomainLevelResourceListInput struct {
DomainLevelResourceListInput
StatusResourceBaseListInput
}
type EnabledStatusDomainLevelResourceListInput struct {
StatusDomainLevelResourceListInput
EnabledResourceBaseListInput
}
type JointResourceBaseListInput struct {
ResourceBaseListInput
}
type VirtualJointResourceBaseListInput struct {
JointResourceBaseListInput
}
type ExternalizedResourceBaseListInput struct {
// 以资源外部ID过滤
ExternalId string `json:"external_id"`
}
type DeletePreventableResourceBaseListInput struct {
// 是否禁止删除
DisableDelete *bool `json:"disable_delete"`
}
type ScopedResourceBaseListInput struct {
ProjectizedResourceListInput
// 指定匹配的范围,可能值为project, domain or system
BelongScope string `json:"belong_scope"`
}
type InfrasResourceBaseListInput struct {
DomainLevelResourceListInput
SharableResourceBaseListInput
}
type StatusInfrasResourceBaseListInput struct {
InfrasResourceBaseListInput
StatusResourceBaseListInput
}
type EnabledStatusInfrasResourceBaseListInput struct {
StatusInfrasResourceBaseListInput
EnabledResourceBaseListInput
}