Files
cloudpods/pkg/apis/list.go
2020-04-16 23:24:56 +08:00

267 lines
9.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 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
ProjectDomains []string `json:"project_domains"`
// 按domain名称排序可能值为asc|desc
// pattern: asc|desc
OrderByDomain string `json:"order_by_domain"`
}
type ProjectizedResourceListInput struct {
DomainizedResourceListInput
ProjectizedResourceInput
// 对具有项目属性的资源严格匹配项目ID
Projects []string `json:"projects"`
// 按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 UserResourceListInput struct {
// 查询指定的用户ID或名称拥有的资源
User string `json:"user"`
// swagger:ignore
// Deprecated
// Filter by userId
UserId string `json:"user_id" "yunion:deprecated-by":"user"`
}
type ModelBaseListInput struct {
Meta
// 查询限制量
// default: 20
Limit *int `json:"limit"`
// 查询偏移量
// 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为关联表columnorigin_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 StandaloneResourceListInput struct {
ResourceBaseListInput
// 通过标签过滤
Tags []STag `json:"tags"`
// 通过标签过滤
OrderByTag string `json:"order_by_tag"`
// 返回资源的标签不包含特定的用户标签
WithoutUserMeta bool `json:"without_user_meta"`
// 返回列表数据中包含资源的标签数据Metadata
WithMeta *bool `json:"with_meta"`
// 显示所有的资源,包括模拟的资源
ShowEmulated *bool `json:"show_emulated"`
// 以资源名称过滤列表
Names []string `json:"name"`
// 以资源ID过滤列表
Ids []string `json:"id"`
}
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
}
type InfrasResourceBaseListInput struct {
DomainLevelResourceListInput
SharableResourceBaseListInput
}
type StatusInfrasResourceBaseListInput struct {
InfrasResourceBaseListInput
StatusResourceBaseListInput
}
type EnabledStatusInfrasResourceBaseListInput struct {
StatusInfrasResourceBaseListInput
EnabledResourceBaseListInput
}