×

POST /v1/collections

描述

参数

请求体参数

名称 描述 必填 默认值 模式

请求体

V1CreateCollectionRequest

内容类型

  • application/json

响应

表1. HTTP响应代码
代码 消息 数据类型

200

成功的响应。

V1CreateCollectionResponse

0

意外的错误响应。

GooglerpcStatus

示例

常用对象引用

GooglerpcStatus

字段名 必填 可空 类型 描述 格式

code

整数

int32

message

字符串

details

ProtobufAny 列表

ProtobufAny

Any 包含任意序列化的协议缓冲区消息以及描述序列化消息类型的URL。

Protobuf库提供支持,以实用程序函数或Any类型的附加生成方法的形式打包/解包Any值。

示例1:在C++中打包和解包消息。

Foo foo = ...;
Any any;
any.PackFrom(foo);
...
if (any.UnpackTo(&foo)) {
  ...
}

示例2:在Java中打包和解包消息。

Foo foo = ...;
Any any = Any.pack(foo);
...
if (any.is(Foo.class)) {
  foo = any.unpack(Foo.class);
}
// or ...
if (any.isSameTypeAs(Foo.getDefaultInstance())) {
  foo = any.unpack(Foo.getDefaultInstance());
}
Example 3: Pack and unpack a message in Python.
foo = Foo(...)
any = Any()
any.Pack(foo)
...
if any.Is(Foo.DESCRIPTOR):
  any.Unpack(foo)
  ...
Example 4: Pack and unpack a message in Go
foo := &pb.Foo{...}
any, err := anypb.New(foo)
if err != nil {
  ...
}
...
foo := &pb.Foo{}
if err := any.UnmarshalTo(foo); err != nil {
  ...
}

Protobuf库提供的打包方法默认使用“type.googleapis.com/full.type.name”作为类型URL,解包方法只使用类型URL中最后一个'/'之后的完全限定类型名,例如“foo.bar.com/x/y.z”将产生类型名“y.z”。

JSON表示

Any值的JSON表示使用反序列化的嵌入式消息的常规表示,以及包含类型URL的附加字段@type。示例

package google.profile;
message Person {
  string first_name = 1;
  string last_name = 2;
}
{
  "@type": "type.googleapis.com/google.profile.Person",
  "firstName": <string>,
  "lastName": <string>
}

如果嵌入式消息类型是众所周知的并且具有自定义JSON表示,则该表示将被嵌入,添加一个字段value,该字段除了@type字段外还包含自定义JSON。示例(对于消息[google.protobuf.Duration][])

{
  "@type": "type.googleapis.com/google.protobuf.Duration",
  "value": "1.212s"
}
字段名 必填 可空 类型 描述 格式

@type

字符串

一个URL/资源名称,唯一标识序列化协议缓冲区消息的类型。此字符串必须包含至少一个“/”字符。URL路径的最后一部分必须表示类型的完全限定名称(如path/google.protobuf.Duration)。名称应采用规范形式(例如,不接受前导“.”)。实际上,团队通常会预先编译它们预期在Any上下文中使用的所有类型到二进制文件中。但是,对于使用方案httphttps或无方案的URL,可以选择设置一个类型服务器,其映射类型URL到消息定义,如下所示:* 如果未提供方案,则假定为https。* 对URL的HTTP GET请求必须以二进制格式产生一个[google.protobuf.Type][]值,或产生错误。* 应用程序允许根据URL缓存查找结果,或将其预编译到二进制文件中以避免任何查找。因此,需要在类型更改时保留二进制兼容性。(使用版本化的类型名称来管理重大更改。)注意:此功能目前在官方protobuf版本中不可用,并且不适用于以type.googleapis.com开头的类型URL。截至2023年5月,没有广泛使用的类型服务器实现,也没有计划实现一个。除了httphttps(或空方案)之外的方案可能会与特定于实现的语义一起使用。

ResourceCollectionEmbeddedResourceCollection

字段名 必填 可空 类型 描述 格式

id

字符串

StorageBooleanOperator

枚举值

OR

AND

StorageMatchType

枚举值

EXACT

REGEX

StorageResourceCollection

字段名 必填 可空 类型 描述 格式

id

字符串

name

字符串

description

字符串

createdAt

日期

日期时间

lastUpdated

日期

日期时间

createdBy

StorageSlimUser

updatedBy

StorageSlimUser

resourceSelectors

StorageResourceSelector 列表

resource_selectors 相互之间以及与embedded_collections中的选择器一起解析为析取(OR)。对于MVP,从UX角度来看,resource_selectors 的大小最多为1。

embeddedCollections

ResourceCollectionEmbeddedResourceCollection 列表

StorageResourceSelector

字段名 必填 可空 类型 描述 格式

rules

StorageSelectorRule 列表

rules 解析为合取(AND)。

StorageRuleValue

字段名 必填 可空 类型 描述 格式

value

字符串

matchType

StorageMatchType

EXACT, REGEX,

StorageSelectorRule

字段名 必填 可空 类型 描述 格式

fieldName

字符串

operator

StorageBooleanOperator

OR, AND,

values

StorageRuleValue 列表

values 根据运算符解析为合取(AND)或析取(OR)。对于MVP,从UX角度来看,只支持OR。

StorageSlimUser

字段名 必填 可空 类型 描述 格式

id

字符串

name

字符串

V1CreateCollectionRequest

字段名 必填 可空 类型 描述 格式

name

字符串

description

字符串

resourceSelectors

StorageResourceSelector 列表

embeddedCollectionIds

string 列表

V1CreateCollectionResponse

字段名 必填 可空 类型 描述 格式

collection

StorageResourceCollection