更新时间:2025-05-19 GMT+08:00
分享

创建工具

功能介绍

该接口用于创建工具。

调用方法

请参见如何调用API

URI

POST https://aiae.appstage.myhuaweicloud.com/v1/workflow-adapter-open/connectors

请求参数

表1 请求Header参数

参数

是否必选

参数类型

描述

Authorization

String

参数解释:

鉴权信息。获取平台API Key,并为API Key添加前缀Bearer,得到标准鉴权信息,例如Bearer sk-74e4157***。API Key获取方法请参见创建API Key

约束限制:

不涉及。

取值范围:

不涉及。

默认取值:

不涉及。

表2 请求Body参数

参数

是否必选

参数类型

描述

icon

String

参数解释:

工具图标的Base64编码。

约束限制:

不涉及。

swagger

swagger object

参数解释:

工具对应的API信息。

约束限制:

不涉及。

auth_content

auth_content object

参数解释:

认证方式。目前支持基本认证、API Key、IAM、AK/SK、自定义、无验证。其中,自定义认证方式不填写此字段。

约束限制:

不涉及。

表3 swagger

参数

是否必选

参数类型

描述

swagger

String

参数解释:

API信息使用swagger格式的版本。

约束限制:

填写2.0。

info

info object

参数解释:

工具的基本信息

约束限制:

不涉及。

schemas

Array of strings

参数解释:

工具对应的API使用的协议。

约束限制:

填写http或https。

host

String

参数解释:

工具对应的API的主机地址。

约束限制:

格式正确的IP或域名。

basePath

String

参数解释:

工具对应的API的基准URL,即域名的根路径。

约束限制:

必须以/开头,且不能有连续多个/,不包含除/._-以外的特殊字符和空格。

securityDefinitions

Object

参数解释:

工具对应的API的验证方式,目前支持基本认证、API Key、IAM、AK/SK、自定义、无验证。使用基本认证、API Key、无验证方式认证时填写此字段。

它们分别对应的json格式分别为:

1.基本认证:

{

"basicAuth": {

"type": "basic"

}

}

2.API Key:

{

"ApiKeyAuth": {

"type": "apiKey",

"in": "header",

"name": "X-API-Key"

}

}

其中,in可以为header或query,name为用户填入的参数名称。

3.无验证:

{}

约束限制:

不涉及。

security

Array of objects

参数解释:

工具对应的API的验证方式。

约束限制:

不涉及。

x-hw-securityDefinitions

Object

参数解释:

工具对应的API的验证方式,目前支持基本认证、API Key、IAM、AK/SK、自定义、无验证。使用IAM、AK/SK、自定义、无验证方式认证时填写此字段。

它们分别对应的json格式分别为:

1.IAM:

{

"iam": {

"type": "iam"

}

}

2.AK/SK:

{

"aksk": {

"type": "aksk"

}

}

3.自定义:

{

"custom_auth": {

"type": "custom_auth",

"const": {

"Authorization": {

"label": "Authorization",

"required": true,

"type": "string",

"value": null,

"x-hw-visibility": null,

"format": null,

"description": "description"

}

},

"authParams": {

"Authorization": {

"source": "const",

"sourceKey": "Authorization",

"position": "HEADER"

}

},

"flow": {}

}

}

其中,Authorization是自定义入参的参数名称,required表示是否必填,type为参数类型,description为参数描述,position可以为HEADER、BODY、QUERY,format为"password"时,表示值加密,null表示非加密。

约束限制:

不涉及。

x-hw-security

Array of objects

参数解释:

工具对应的API的验证方式。

约束限制:

不涉及。

表4 info

参数

是否必选

参数类型

描述

version

String

参数解释:

工具版本。

约束限制:

填写1.0.0。

title

String

参数解释:

工具名称。

约束限制:

只能由中英文、数字、下划线、中划线、英文小括号组成,只能使用中英文以及数字开头,且长度不能超过32个字符。

description

String

参数解释:

工具描述。

约束限制:

只能包含中英文、数字、下划线、中划线、空格及,.?:;"':;“”‘’,。?、()()/@!!*%#等,且长度不能超过256个字符。

x-can-modify-host-address

Boolean

参数解释:

工具的host是否可更改。

约束限制:

填写true或false。

表5 auth_content

参数

是否必选

参数类型

描述

auth_type

String

参数解释:

认证方式。目前支持基本认证、API Key、IAM、AK/SK、无验证。其中,基本认证、API Key、IAM、AK/SK、无验证分别填写basic、apiKey、iam、aksk、none。

约束限制:

不涉及。

auth_info

Object

参数解释:

认证方式。目前支持基本认证、API Key、IAM、AK/SK、自定义、无验证。其中:

1.基本认证填写:{}

2.API Key填写:{}

3.IAM填写:{}

4.AK/SK填写:{}

5.无验证填写:{}

约束限制:

不涉及。

auth_config

Object

参数解释:

认证方式。目前支持基本认证、API Key、IAM、AK/SK、无验证。其中:

1.基本认证填写:{}

2.API Key填写:{

"in": "header",

"name": "X-API-Key"

}

3.IAM填写:{}

4.AK/SK填写:{}

5.无验证填写:{}

约束限制:

不涉及。

auth_prop

Object

参数解释:

认证方式。目前支持基本认证、API Key、IAM、AK/SK、无验证。其中:

1.基本认证填写:{}

2.API Key填写:{}

3.IAM填写:{}

4.AK/SK填写:{}

5.无验证填写:{}

约束限制:

不涉及。

auth_dynamic

Object

参数解释:

认证方式。目前支持基本认证、API Key、IAM、AK/SK、自定义、无验证。其中:

1.基本认证填写:{}

2.API Key填写:{}

3.IAM填写:{}

4.AK/SK填写:{}

5.无验证填写:{}

约束限制:

不涉及。

响应参数

状态码:200

表6 响应Body参数

参数

参数类型

描述

-

String

参数解释:

创建出的工具的ID。

约束限制:

不涉及。

状态码:500

表7 响应Body参数

参数

参数类型

描述

error_code

String

参数解释:

错误码。

取值范围:

不涉及。

error_msg

String

参数解释:

错误信息。

取值范围:

不涉及。

请求示例

{
  "icon" : "base64 string",
  "swagger" : {
    "swagger" : {
      "info" : {
        "version" : "1.0.0",
        "title" : "example name",
        "description" : "example description",
        "x-can-modify-host-address" : false
      },
      "schemes" : [ "https" ],
      "host" : "example.com",
      "basePath" : "/",
      "securityDefinitions" : {
        "ApiKeyAuth" : {
          "type" : "apiKey",
          "in" : "header",
          "name" : "X-API-Key"
        }
      },
      "security" : [ {
        "ApiKeyAuth" : [ ]
      } ]
    }
  },
  "auth_content" : {
    "auth_type" : "apiKey",
    "auth_info" : { },
    "auth_config" : {
      "in" : "header",
      "name" : "X-API-Key"
    },
    "auth_prop" : { },
    "auth_dynamic" : { }
  }
}

响应示例

状态码:200

成功。

{
  "data" : "tool id"
}

状态码:500

服务器内部错误或三方服务器内部错误。

{
  "error_code" : "AIAE.22009001",
  "error_msg" : "Internal Server Error."
}

状态码

状态码

描述

200

成功。

500

服务器内部错误或三方服务器内部错误。

错误码

请参见错误码

相关文档