跳到主要内容

集成中心

集成中心(Integration)提供集成模板与集成实例(密钥对,UserKey)的增删改查能力,封装自云 API(tcb 2018-06-08),所有请求统一携带 Business='integration'

通过 manager.integration 访问,例如:

const { integration } = new CloudBase({
secretId: 'Your SecretId',
secretKey: 'Your SecretKey',
envId: 'Your envId' // 云开发环境ID,可在腾讯云云开发控制台获取
})
说明

本服务只做云 API 的纯封装:不识别模板字段、不做敏感字段加解密、也不做「绑定资源」这类编排逻辑。模板结构、加密密钥、上层交互由调用方(CLI / 控制台)自行处理,最终把配置拼装为 Ext JSON 字符串传入。

listTemplates

1. 接口描述

接口功能:获取集成模板(密钥对模版)列表

接口声明:listTemplates(params?: IListTemplatesParams): Promise<IGetUserKeyTemplateListResult>

2. 输入参数

IListTemplatesParams

字段必填类型说明
offsetNumber偏移量,默认 0
limitNumber返回数量,默认 100
authTypeCodeString按授权类型码筛选
authTypeNameString按授权类型名称筛选
businessString业务类型,集成中心传入 integration

3. 返回结果

IGetUserKeyTemplateListResult

字段必填类型说明
RequestIdString请求唯一标识
TotalCountNumber模板总数
KeyTemplateListArray<IUserKeyTemplate>模板列表

IUserKeyTemplate

字段必填类型说明
AuthTypeCodeString授权类型码(模板 Key)
AuthTypeNameString授权类型名称(模板中文名)
ExtString模板动态信息 JSON 字符串,含 fields 定义
AuthURLString授权 URL(OAuth 类模板)
IconString模板图标
StateString状态
RedirectURIString回调地址

4. 示例代码

const res = await integration.listTemplates({
limit: 20,
business: 'integration'
})
console.log(res.KeyTemplateList)

listUserKeys

1. 接口描述

接口功能:获取集成实例(密钥对)列表

接口声明:listUserKeys(params?: IListUserKeysParams): Promise<IGetUserKeyListResult>

2. 输入参数

IListUserKeysParams

字段必填类型说明
nameString按名称筛选(模糊匹配)
authTypeCodeString按授权类型码筛选
offsetNumber偏移量,默认 0
limitNumber返回数量,默认 100
businessString业务类型,集成中心传入 integration

3. 返回结果

IGetUserKeyListResult

字段必填类型说明
RequestIdString请求唯一标识
TotalCountNumber实例总数
UserKeyListArray<IUserKeyInfo>实例列表

IUserKeyInfo

字段必填类型说明
NameString集成实例名称
KeyIDString集成实例标识(唯一)
AuthTypeCodeString授权类型码
AuthTypeNameString授权类型名称
ExtString配置信息 JSON 字符串(含加密后的敏感字段值)
DescriptionString描述
StatusString状态
TicketIDStringOAuth 类授权 ticket id
DemoCodeFunctionNameString绑定的示例代码云函数名称
BindServiceListObject已绑定服务列表(Mcp / Apis / Other 等分组)
CreateAtString创建时间(ISO 8601)
UpdateAtString更新时间(ISO 8601)

4. 示例代码

const res = await integration.listUserKeys({
name: 'my-key',
business: 'integration'
})
console.log(res.UserKeyList)

getUserKey

1. 接口描述

接口功能:获取单个集成实例详情

接口声明:getUserKey(params: IGetUserKeyParams): Promise<IGetOneUserKeyResult>

2. 输入参数

IGetUserKeyParams

字段必填类型说明
keyIdString集成实例标识
needPwdBooleantrue 时返回加密字段的密文值,默认 false
businessString业务类型,集成中心传入 integration

3. 返回结果

IGetOneUserKeyResult

字段必填类型说明
RequestIdString请求唯一标识
UserKeyInfoIUserKeyInfo集成实例详情

UserKeyInfo 字段定义见 listUserKeys

4. 示例代码

const res = await integration.getUserKey({
keyId: 'my-key-id',
business: 'integration'
})
console.log(res.UserKeyInfo)

createUserKey

1. 接口描述

接口功能:创建集成实例

接口声明:createUserKey(params: ICreateUserKeyParams): Promise<ICreateUserKeyResult>

ext 为最终写入的 JSON 字符串,由调用方按模板字段自行拼装(含敏感字段加密),SDK 不做任何解析或加工,原样传递给云 API。

2. 输入参数

ICreateUserKeyParams

字段必填类型说明
nameString集成实例名称
authTypeCodeString授权类型码
descriptionString描述
extString配置信息 JSON 字符串(含敏感字段密文)
keyIdString指定实例标识(不指定则由后端生成)
ticketIdStringOAuth 类授权 ticket id
demoCodeFunctionNameString绑定的示例代码云函数名称
runtimeConfigRecord<string, any>Agent 云函数配置
businessString业务类型,集成中心传入 integration

3. 返回结果

ICreateUserKeyResult

字段必填类型说明
RequestIdString请求唯一标识
CreateResultNumber创建结果(0 表示成功)
DemoCodeFunctionNameString示例代码云函数名称

4. 示例代码

const res = await integration.createUserKey({
name: 'my-payment',
authTypeCode: 'weixinpaydc',
ext: JSON.stringify({ appId: 'xxx', secret: 'encrypted-value' }),
business: 'integration'
})
console.log(res)

updateUserKey

1. 接口描述

接口功能:更新集成实例

接口声明:updateUserKey(params: IUpdateUserKeyParams): Promise<IUpdateUserKeyResult>

ext 由调用方自行完成「与现有 Ext 合并」等编排后传入;未传 ext 时后端保留原有 Ext 不变。

2. 输入参数

IUpdateUserKeyParams

字段必填类型说明
keyIdString集成实例标识
nameString集成实例名称
authTypeCodeString授权类型码
descriptionString描述
extString配置信息 JSON 字符串(含敏感字段密文)
demoCodeFunctionNameString绑定的示例代码云函数名称(bind-resource 使用)
runtimeConfigRecord<string, any>Agent 云函数配置
businessString业务类型,集成中心传入 integration

3. 返回结果

IUpdateUserKeyResult

字段必填类型说明
RequestIdString请求唯一标识
UpdateResultNumber更新结果(0 表示成功)

4. 示例代码

const res = await integration.updateUserKey({
keyId: 'my-key-id',
description: '更新描述',
business: 'integration'
})
console.log(res)

deleteUserKey

1. 接口描述

接口功能:删除集成实例

接口声明:deleteUserKey(params: IDeleteUserKeyParams): Promise<IDeleteUserKeyResult>

2. 输入参数

IDeleteUserKeyParams

字段必填类型说明
keyIdString集成实例标识

3. 返回结果

IDeleteUserKeyResult

字段必填类型说明
RequestIdString请求唯一标识
DeleteResultNumber删除结果(0 表示成功)

4. 示例代码

const res = await integration.deleteUserKey({
keyId: 'my-key-id'
})
console.log(res)