Skip to main content

数据中心集合

kscli collection 与 category 命令组,管理数据中心的容器与分类层级

集合(collection)是数据中心的顶层容器,分类(category)用于组织集合内的文件并支持多级嵌套。本组共 5 个命令。 鉴权、业务空间 ID、全局参数、输出格式、二次确认等通用约定见 CLI 概述。以下示例默认已通过配置文件设置业务空间 ID。

kscli collection create

创建文件数据集合。
kscli collection create --name <text> --description <text> [flags]
参数
参数类型必填说明
--name <text>string是集合名称,1–20 字符
--description <text>string是集合描述
--store-type <type>string否存储类型,platform(平台托管,默认)或 custom(自有 OSS bucket)
--oss-region <id>string否OSS 地域 ID,--store-type custom 时必填
--oss-bucket <name>string否OSS bucket 名称,--store-type custom 时必填
输出
created: coll-xxx  (my-collection, PLATFORM)
quiet 模式输出集合 ID。json 模式返回完整结果。
平台暂不支持删除数据集合,CLI 也没有对应命令。创建前请确认命名与用途。如需隔离数据,创建新集合并迁移文件。
使用自有 OSS bucket --store-type custom 要求 bucket 已授权给平台。除了 RAM 角色授权外,bucket 还必须携带标签 bailian-connector-access=ReadAndWrite。缺少该标签时创建会失败,且错误提示可能指向 CORS 配置,实际原因是缺少此标签。 示例
# 平台托管存储
kscli collection create --name my-collection --description "team docs"

# 自有 OSS bucket
kscli collection create --name oss-coll --description "own bucket" \
  --store-type custom --oss-region cn-beijing --oss-bucket my-bucket

kscli collection get

查看数据集合详情。
kscli collection get (--collection-id <id> | --name <text>) [flags]
参数
参数类型必填说明
--collection-id <id>string二选一集合 ID;与 --name 互斥
--name <text>string二选一集合名称;与 --collection-id 互斥
两者互斥,必须提供其中一个。 输出
id: coll-xxx
name: my-collection
description: team docs
quiet 模式输出集合 ID。json 模式返回完整结果。 存储配置(存储类型、OSS 地域与 bucket)仅在创建时指定,查询结果中不返回。 示例
# 按 ID 查询
kscli collection get --collection-id coll-xxx

# 按名称查询
kscli collection get --name my-collection

kscli category list

列出数据中心分类。
kscli category list [flags]
参数
参数类型必填说明
--collection-id <id>string否按集合 ID 精确过滤
--parent-id <id>string否列出此分类的子分类
--name <text>string否按分类名称精确过滤
--next-token <token>string否游标分页令牌,从上次输出获取
--max-result <n>number否每页条数,默认 20
输出
cate-xxx  product-docs
cate-yyy  system-docs  [default]
next: --next-token eyJ...
标记 [default] 的分类是文件未指定分类时的默认归属。 quiet 模式每行输出一个分类 ID。json 模式返回完整结果。 本命令使用游标分页,将输出末行提示的 --next-token <token> 传入下一次调用即可翻页。 --name 是精确匹配,与 kb list --name 的模糊匹配行为不同。 示例
# 列出全部分类
kscli category list

# 按名称精确查找
kscli category list --name my-category

# 列出子分类
kscli category list --parent-id cate-xxx

# 翻页
kscli category list --next-token eyJ...

kscli category add

创建数据中心分类。
kscli category add --name <text> [flags]
参数
参数类型必填说明
--name <text>string是分类名称,1–20 字符
--parent-id <id>string否创建为此分类的子分类
--collection-id <id>string否创建在此集合下,默认为平台集合
输出
created: cate-xxx  (product-docs)
quiet 模式输出分类 ID。json 模式返回完整结果。 新建的分类 ID 可作为 doc upload --category-id、kb create --category-id 或 file list --category-id 的入参。 示例
# 创建分类
kscli category add --name product-docs

# 创建子分类
kscli category add --name sub --parent-id cate-xxx

kscli category delete

删除数据中心分类。
kscli category delete --category-id <id> [flags]
参数
参数类型必填说明
--category-id <id>string是分类 ID
--yesswitch否跳过确认提示
输出
deleted: cate-xxx
quiet 模式无输出。json 模式返回完整结果。 删除包含文件或子分类的分类时,是否允许以服务端返回结果为准,报错信息会原样展示。建议先用 kscli file list --category-id 确认分类为空。 示例
# 交互确认后删除
kscli category delete --category-id cate-xxx

# 跳过确认
kscli category delete --category-id cate-xxx --yes