list.go 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. // Copyright 2019 Yunion
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package apis
  15. import (
  16. "time"
  17. "yunion.io/x/onecloud/pkg/util/tagutils"
  18. )
  19. type ScopedResourceInput struct {
  20. // 指定查询的权限范围,可能值为project, domain or system
  21. Scope string `json:"scope"`
  22. }
  23. type DomainizedResourceListInput struct {
  24. ScopedResourceInput
  25. DomainizedResourceInput
  26. // 对具有域属性的资源,严格匹配域ID
  27. ProjectDomainIds []string `json:"project_domain_ids"`
  28. // Deprecated
  29. // swagger:ignore
  30. ProjectDomains []string `json:"project_domains" yunion-deprecated-by:"project_domain_ids"`
  31. // 按domain名称排序,可能值为asc|desc
  32. // pattern: asc|desc
  33. OrderByDomain string `json:"order_by_domain"`
  34. // filter by domain tags
  35. DomainTags tagutils.TTagSetList `json:"domain_tags"`
  36. // filter by domain tags
  37. NoDomainTags tagutils.TTagSetList `json:"no_domain_tags"`
  38. // ignore
  39. // domain tags filters imposed by policy
  40. // PolicyDomainTags tagutils.TTagSetList `json:"policy_domain_tags"`
  41. }
  42. type ProjectizedResourceListInput struct {
  43. DomainizedResourceListInput
  44. ProjectizedResourceInput
  45. // 对具有项目属性的资源,严格匹配项目ID
  46. ProjectIds []string `json:"project_ids"`
  47. // Deprecated
  48. // swagger:ignore
  49. Projects []string `json:"projects" yunion-deprecated-by:"project_ids"`
  50. // 按project名称排序,可能值为asc|desc
  51. // pattern: asc|desc
  52. OrderByProject string `json:"order_by_project"`
  53. // swagger:ignore
  54. // Deprecated
  55. OrderByTenant string `json:"order_by_tenant" yunion-deprecated-by:"order_by_project"`
  56. // filter by project tags
  57. ProjectTags tagutils.TTagSetList `json:"project_tags"`
  58. // filter by no project tags
  59. NoProjectTags tagutils.TTagSetList `json:"no_project_tags"`
  60. // filter by project organizations
  61. ProjectOrganizations []string `json:"project_organizations"`
  62. // ignore
  63. // project tag fitlers imposed by policy
  64. PolicyProjectTags tagutils.TTagSetList `json:"policy_project_tags"`
  65. }
  66. type StatusDomainLevelUserResourceListInput struct {
  67. StatusDomainLevelResourceListInput
  68. // 查询指定的用户(ID或名称)拥有的资源
  69. UserId string `json:"user_id"`
  70. // swagger:ignore
  71. // Deprecated
  72. // Filter by userId
  73. User string `json:"user" yunion-deprecated-by:"user_id"`
  74. }
  75. type UserResourceListInput struct {
  76. StandaloneResourceListInput
  77. ScopedResourceInput
  78. // swagger:ignore
  79. // Is an admin call? equivalent to scope=system
  80. // Deprecated
  81. Admin *bool `json:"admin"`
  82. // 查询指定的用户(ID或名称)拥有的资源
  83. UserId string `json:"user_id"`
  84. // swagger:ignore
  85. // Deprecated
  86. // Filter by userId
  87. User string `json:"user" yunion-deprecated-by:"user_id"`
  88. }
  89. type ModelBaseListInput struct {
  90. Meta
  91. // 查询限制量
  92. // default: 20
  93. Limit *int `json:"limit" default:"20" help:"max items per page"`
  94. // 查询偏移量
  95. // default: 0
  96. Offset *int `json:"offset"`
  97. // 列表排序时,用于排序的字段的名称,该字段不提供时,则按默认字段排序。一般时按照资源的新建时间逆序排序。
  98. OrderBy []string `json:"order_by"`
  99. // 列表排序时的顺序,desc为从高到低,asc为从低到高。默认是按照资源的创建时间desc排序。
  100. // example: desc|asc
  101. Order string `json:"order"`
  102. // 列表返回资源的更多详细信息。默认只显示基本字段,该字段为true则返回扩展字段信息。
  103. Details *bool `json:"details"`
  104. // 模糊搜索所有字段
  105. Search string `json:"search"`
  106. // 指定过滤条件,允许指定多个,每个条件的格式为"字段名称.操作符(匹配信息)",例如name字段等于test的过滤器为:name.equals('test')
  107. // 支持的操作符如下:
  108. //
  109. // | 操作符 | 参数个数 | 举例 | 说明 |
  110. // |---------------|----------|------------------------------------------------|-----------------------------|
  111. // | in | > 0 | name.in("test", "good") | 在给定数组中 |
  112. // | notin | > 0 | name.notin('test') | 不在给定数组中 |
  113. // | between | 2 | created_at.between('2019-12-10', '2020-01-02') | 在两个值之间 |
  114. // | ge | 1 | created_at.ge('2020-01-01') | 大于或等于给定值 |
  115. // | gt | 1 | created_at.gt('2020-01-01') | 严格大于给定值 |
  116. // | le | 1 | created_at.le('2020-01-01') | 小于或等于给定值 |
  117. // | lt | 1 | sync_seconds.lt(900) | 严格大于给定值 |
  118. // | like | > 0 | name.like('%test%') | sql字符串匹配任意一个字符串 |
  119. // | contains | > 0 | name.contains('test') | 包含任意一个给定字符串 |
  120. // | startswith | > 0 | name.startswith('test') | 以任意一个给定字符串开头 |
  121. // | endswith | > 0 | name.endswith('test') | 以任意一个给定字符串结尾 |
  122. // | equals | > 0 | name.equals('test') | 等于任意一个给定值 |
  123. // | notequals | 1 | name.notequals('test') | 不等于给定值 |
  124. // | isnull | 0 | name.isnull() | 值为SQL的NULL |
  125. // | isnotnull | 0 | name.isnotnull() | 值不为SQL的NULL |
  126. // | isempty | 0 | name.isempty('test') | 值为空字符串 |
  127. // | isnotempty | 0 | name.isnotempty('test') | 值不是空字符串 |
  128. // | isnullorempty | 0 | name.isnullorempty('test') | 值为SQL的NULL或者空字符串 |
  129. //
  130. Filter []string `json:"filter"`
  131. // 指定关联过滤条件,允许指定多个,后端将根据关联过滤条件和其他表关联查询,支持的查询语法和filter相同,
  132. // 和其他表关联的语法如下:
  133. // joint_resources.related_key(origin_key).filter_col.filter_ops(values)
  134. // 其中,joint_resources为要关联的资源名称,related_key为关联表column,origin_key为当前表column, filter_col为
  135. // 关联表用于查询匹配的field名称,field_ops为filter支持的操作,values为匹配的值
  136. // 举例:
  137. // guestnetworks.guest_id(id).ip_addr.equals('10.168.21.222')
  138. JointFilter []string `json:"joint_filter"`
  139. // 如果filter_any为true,则查询所有filter的并集,否则为交集
  140. FilterAny *bool `json:"filter_any"`
  141. // 返回结果只包含指定的字段
  142. Field []string `json:"field"`
  143. // 用于数据导出,指定导出的数据字段
  144. ExportKeys string `json:"export_keys" help:"Export field keys"`
  145. // 返回结果携带delete_fail_reason和update_fail_reason字段
  146. ShowFailReason *bool `json:"show_fail_reason"`
  147. // 是否返回状态统计信息,默认为False
  148. SummaryStats *bool `json:"summary_stats"`
  149. }
  150. func (o ModelBaseListInput) GetExportKeys() string {
  151. return o.ExportKeys
  152. }
  153. type IncrementalListInput struct {
  154. // 用于指定增量加载的标记
  155. PagingMarker string `json:"paging_marker"`
  156. }
  157. type VirtualResourceListInput struct {
  158. StatusStandaloneResourceListInput
  159. ProjectizedResourceListInput
  160. // 列表中包含标记为"系统资源"的资源
  161. System *bool `json:"system"`
  162. // 是否显示回收站内的资源,默认不显示(对实现了回收站的资源有效,例如主机,磁盘,镜像)
  163. PendingDelete *bool `json:"pending_delete"`
  164. // 是否显示所有资源,包括回收站和不再回收站的资源
  165. // TODO: fix this???
  166. PendingDeleteAll *bool `json:"-"`
  167. }
  168. type ResourceBaseListInput struct {
  169. ModelBaseListInput
  170. }
  171. type SharableVirtualResourceListInput struct {
  172. VirtualResourceListInput
  173. SharableResourceBaseListInput
  174. // 根据资源的共享范围过滤列表,可能值为:system, domain, project
  175. PublicScope string `json:"public_scope"`
  176. }
  177. type AdminSharableVirtualResourceListInput struct {
  178. SharableVirtualResourceListInput
  179. }
  180. type MetadataResourceListInput struct {
  181. // 通过标签过滤(包含这些标签)
  182. Tags tagutils.TTagSet `json:"tags"`
  183. // 通过一组标签过滤(还包含这些标签,OR的关系)
  184. ObjTags tagutils.TTagSetList `json:"obj_tags"`
  185. // 通过标签过滤(不包含这些标签)
  186. NoTags tagutils.TTagSet `json:"no_tags"`
  187. // 通过一组标签过滤(还不包含这些标签,AND的关系)
  188. NoObjTags tagutils.TTagSetList `json:"no_obj_tags"`
  189. // ignore
  190. // 策略规定的标签过滤器
  191. // PolicyObjectTags tagutils.TTagSetList `json:"policy_object_tags"`
  192. // 通过标签排序
  193. OrderByTag string `json:"order_by_tag"`
  194. // deprecated
  195. // 返回资源的标签不包含用户标签
  196. WithoutUserMeta *bool `json:"without_user_meta"`
  197. // 返回包含用户标签的资源
  198. WithUserMeta *bool `json:"with_user_meta"`
  199. // 返回包含外部标签的资源
  200. WithCloudMeta *bool `json:"with_cloud_meta"`
  201. // 返回包含任意标签的资源
  202. WithAnyMeta *bool `json:"with_any_meta"`
  203. // 返回列表数据中包含资源的标签数据(Metadata)
  204. WithMeta *bool `json:"with_meta"`
  205. }
  206. type StandaloneAnonResourceListInput struct {
  207. ResourceBaseListInput
  208. MetadataResourceListInput
  209. // 显示所有的资源,包括模拟的资源
  210. ShowEmulated *bool `json:"show_emulated" help:"show emulated resources" negative:"do not show emulated resources"`
  211. // 以资源ID过滤列表
  212. Ids []string `json:"id" help:"filter by ids"`
  213. }
  214. type StandaloneResourceListInput struct {
  215. StandaloneAnonResourceListInput
  216. // 以资源名称过滤列表
  217. Names []string `json:"name" help:"filter by names"`
  218. }
  219. type StatusResourceBaseListInput struct {
  220. // 以资源的状态过滤列表
  221. Status []string `json:"status"`
  222. }
  223. type EnabledResourceBaseListInput struct {
  224. // 以资源是否启用/禁用过滤列表
  225. Enabled *bool `json:"enabled"`
  226. }
  227. type SharableResourceBaseListInput struct {
  228. // 以资源是否共享过滤列表
  229. IsPublic *bool `json:"is_public"`
  230. // 根据资源的共享范围过滤列表,可能值为:system, domain, project
  231. PublicScope string `json:"public_scope"`
  232. }
  233. type DomainLevelResourceListInput struct {
  234. StandaloneResourceListInput
  235. DomainizedResourceListInput
  236. }
  237. type StatusStandaloneResourceListInput struct {
  238. StandaloneResourceListInput
  239. StatusResourceBaseListInput
  240. }
  241. type EnabledStatusStandaloneResourceListInput struct {
  242. StatusStandaloneResourceListInput
  243. EnabledResourceBaseListInput
  244. }
  245. type StatusDomainLevelResourceListInput struct {
  246. DomainLevelResourceListInput
  247. StatusResourceBaseListInput
  248. }
  249. type EnabledStatusDomainLevelResourceListInput struct {
  250. StatusDomainLevelResourceListInput
  251. EnabledResourceBaseListInput
  252. }
  253. type JointResourceBaseListInput struct {
  254. ResourceBaseListInput
  255. }
  256. type VirtualJointResourceBaseListInput struct {
  257. JointResourceBaseListInput
  258. }
  259. type ExternalizedResourceBaseListInput struct {
  260. // 以资源外部ID过滤
  261. ExternalId string `json:"external_id"`
  262. }
  263. type DeletePreventableResourceBaseListInput struct {
  264. // 是否禁止删除
  265. DisableDelete *bool `json:"disable_delete"`
  266. }
  267. type ScopedResourceBaseListInput struct {
  268. ProjectizedResourceListInput
  269. // 指定匹配的范围,可能值为project, domain or system
  270. BelongScope string `json:"belong_scope"`
  271. }
  272. type InfrasResourceBaseListInput struct {
  273. DomainLevelResourceListInput
  274. SharableResourceBaseListInput
  275. }
  276. type StatusInfrasResourceBaseListInput struct {
  277. InfrasResourceBaseListInput
  278. StatusResourceBaseListInput
  279. }
  280. type EnabledStatusInfrasResourceBaseListInput struct {
  281. StatusInfrasResourceBaseListInput
  282. EnabledResourceBaseListInput
  283. }
  284. type MultiArchResourceBaseListInput struct {
  285. // 通过操作系统架构过滤
  286. // x86会过滤出os_arch为空或os_arch=i386或以x86开头的资源
  287. // arm会过滤出os_arch=aarch64或os_arch=aarch32或者以arm开头的资源
  288. // 其他的输入会过滤出以输入字符开头的资源
  289. // enmu: x86, arm
  290. OsArch []string `json:"os_arch"`
  291. }
  292. type AutoDeleteResourceBaseListInput struct {
  293. AutoDelete *bool
  294. }
  295. type OpsLogListInput struct {
  296. OwnerProjectIds []string `json:"owner_project_ids"`
  297. OwnerDomainIds []string `json:"owner_domain_ids"`
  298. // filter by obj type
  299. ObjTypes []string `json:"obj_type"`
  300. // filter by obj name or obj id
  301. Objs []string `json:"obj"`
  302. // filter by obj ids
  303. ObjIds []string `json:"obj_id"`
  304. // filter by obj name
  305. ObjNames []string `json:"obj_name"`
  306. // filter by action
  307. Actions []string `json:"action"`
  308. Since time.Time `json:"since"`
  309. Until time.Time `json:"until"`
  310. }
  311. type HostDmesgLogListInput struct {
  312. OpsLogListInput
  313. LogLevels []string `json:"log_levels"`
  314. ShowDmesgLog bool `json:"show_dmesg_log"`
  315. }
  316. type IdNameDetails struct {
  317. Id string `json:"id"`
  318. Name string `json:"name"`
  319. }
  320. type TotalCountBase struct {
  321. Count int `json:"count"`
  322. }
  323. type LogBaseListInput struct {
  324. ModelBaseListInput
  325. Id []string `json:"id"`
  326. }