查询模板列表
功能介绍
查询模板列表。
调试
您可以在API Explorer中调试该接口,支持自动认证鉴权。API Explorer可以自动生成SDK代码示例,并提供SDK代码示例调试功能。
URI
POST /v1/templates/query
请求参数
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| X-Auth-Token | 否 | String | 用户Token。 通过调用IAM服务获取用户Token接口获取(响应消息头中X-Subject-Token的值)。 |
| X-Language | 否 | String | 语言类型,缺省值为“zh-cn”。 枚举值:
|
| 参数 | 是否必选 | 参数类型 | 描述 |
|---|---|---|---|
| category | 否 | Array of strings | 模板分类数组。 |
| keyword | 否 | String | 搜索关键字,支持按名称和描述搜索,默认null。 |
| sort_key | 否 | Array of strings | 排序字段。 |
| sort_dir | 否 | Array of strings | 指定排序使用升序还是降序。
|
| label | 否 | String | 标签:
|
| my_templates | 否 | Boolean | 是否查询用户自己创建的模板,默认查所有模板。 |
| status | 否 | Integer | 查所有模板时只处理上架的;查用户模板,需支持按状态查询,状态:
|
| status_array | 否 | Array of integers | 模板状态数组。 |
| has_notices | 否 | Boolean | 是否查询有消息的模板,默认查所有模板。 |
| productshorts | 否 | Array of strings | 模板关联的云产品(产品短名)列表。 |
| offset | 否 | Integer | 偏移量,表示从此偏移量开始查询,offset大于等于0。 |
| limit | 否 | Integer | 每页的模板条数。 |
| tag_ids | 否 | Array of strings | 模板关联的自定义标签列表。 |
| types | 否 | Array of integers | 模板类型:
|
| is_static | 否 | Integer | 动、静态代码模板标识:
|
| platform_source | 否 | Array of integers | 平台来源:
|
| tag_names | 否 | Array of strings | 模板关联的标签名称列表。 |
响应参数
状态码: 200
| 参数 | 参数类型 | 描述 |
|---|---|---|
| count | Integer | 返回模板的数量。 |
| invalid_count | Integer | 返回关联了失效资源的模板数量。 |
| templates | Array of TemplateInfo objects | 返回模板的列表。 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| id | String | 模板id。 |
| title | String | 模板名。 |
| description | String | 模板描述。 |
| productshorts | Array of strings | 模板关联的所有云服务(产品短名)。 |
| products | Array of TemplateProductExt objects | 模板关联的云产品。 |
| topic | Array of TopicCategory objects | 模板标签。 |
| creator_id | String | 模板创建者id。 |
| creator | String | 模板创建者,有别名返回别名。 |
| nickname | String | 模板创建者,有别名返回别名。 |
| score | Integer | 模板评分(点赞数)。 |
| label | String | 模板标签(new、hot等)。 |
| store | Integer | 代码存储位置。 |
| store_info | String | 获取代码模版所需的信息。 |
| status | Integer | 模板状态:
|
| view_count | Integer | 访问量。 |
| usage_count | Integer | 引用量。 |
| created_at | String | 创建时间。 |
| updated_at | String | 更新时间。 |
| published_at | String | 模板上架时间。 |
| favorite_state | Integer | 点赞状态:
|
| tags | Array of TagInfo objects | 模板标签。 |
| type | Integer | 模板类型:
|
| is_static | Integer | 动、静态代码模板标识:
|
| maintainers | Array of strings | 模板相关联的所有维护人账号名称。 |
| pipeline_template | PipelineTemplateInfo object | 流水线模板 |
| platform_source | Integer | 平台来源:
|
| references | Array of Reference objects | 相关文档,示例,帖子。 |
| properties | Object | 模板自定义参数列表。 |
| dependencies | Array of objects | dependency信息。 |
| dependency_type | String | dependency类型。 |
| forum_id | Integer | 关联论坛板块id。 |
| file_size | Integer | 模板文件解压缩之后的大小(单位:KB)。 |
| deployment | Object | 部署信息。 |
| update_id | String | 模板关联更新态Id。 |
| is_support_cloudide | Boolean | 是否支持使用CodeArts IDE Online运行源码。 |
| has_notices | Boolean | 是否有消息 |
| dependents | Array of Dependent objects | 模板部署方式依赖信息 |
| dependent_services | String | 模板关联云服务。 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| id | String | 产品id。 |
| productshort | String | 产品短名。 |
| product_name | String | 产品名。 |
| home_link | String | 首页链接。 |
| api_link | String | api调试链接。 |
| sdk_link | String | sdk下载链接。 |
| doc_link | String | 文档链接。 |
| logo_link | String | logo链接。 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| topic_id | String | topic的id。 |
| topic_name | String | topic的名称。 |
| category_id | String | topic对应的类别的id。 |
| category_name | String | topic对应的类别的名称。 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| id | String | 流水线模板的id。 |
| name | String | 流水线模板的名称。 |
| detail | String | 流水线模板的详细信息。 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| title | String | 标题名称。 |
| url | String | 链接地址。 |
| type | Integer | 关联类型。 |
| productshort | String | 产品短名。 |
| is_valid | Boolean | 是否有效 |
| 参数 | 参数类型 | 描述 |
|---|---|---|
| name | String | 云服务名称。 |
| description | String | 描述。 |
| home_link | String | 首页链接。 |
| subscribe_link | String | 开通链接。 |
| subscribe_guide | String | 开通指导。 |
| type | String | 服务类型。 |
| reference_price | String | 参考价格。 |
| price_details_link | String | 价格详情链接。 |
| specifications | Object | 规格,例如: {"cpu" : "0.5","ram" : 1GB}。 |
状态码: 400
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error_code | String | 错误编码 |
| error_msg | String | 错误原因 |
状态码: 401
| 参数 | 参数类型 | 描述 |
|---|---|---|
| error_code | String | 错误编码 |
| error_msg | String | 错误原因 |
请求示例
POST https://{endpoint}/v1/templates/query
{
"category" : [ "f6662a3f1e9b11eca72efa163e776c82", "f9a026301b5111eca72efa163e776c82" ],
"keyword" : "devstar",
"sort_key" : [ "is_recommend", "usage_count" ],
"sort_dir" : [ "desc", "desc" ],
"label" : "recommend",
"my_templates" : false,
"status" : 1,
"status_array" : [ 0, 1 ],
"has_notices" : false,
"productshorts" : [ "ECS", "VBS" ],
"offset" : 0,
"limit" : 10,
"tag_ids" : [ "005558d30c6e40379eda90445af03270", "013f0593d357415b97be5a5e215f71cf" ],
"types" : [ 0, 1 ],
"is_static" : 0,
"platform_source" : 1,
"tag_names" : [ "test" ]
} 响应示例
状态码: 200
ok
{
"count" : 1,
"invalid_count" : 0,
"templates" : [ {
"id" : "8c114fbf458f44c9a432e93953e3c630",
"title" : "测试",
"description" : "测试",
"productshorts" : [ "OBS" ],
"products" : [ ],
"topic" : [ {
"topic_id" : "ae54b863208f11ea8b68fa163e6e3ea0",
"topic_name" : "官方模板",
"category_id" : "d79c4e0b1fc511ea8b68fa163e6e3ea0",
"category_name" : "模板来源"
}, {
"topic_id" : "e95253901fca11ea8b68fa163e6e3ea0",
"topic_name" : "Java",
"category_id" : "bd3303f51fc411ea8b68fa163e6e3ea0",
"category_name" : "开发语言"
} ],
"nickname" : "tester",
"score" : 0,
"label" : "NEW",
"store" : null,
"store_info" : null,
"status" : 1,
"view_count" : 2,
"usage_count" : 0,
"created_at" : "2021-04-28T10:06:59Z",
"updated_at" : "2021-04-28T10:06:59Z",
"published_at" : "2021-04-28T10:07:16Z",
"tags" : [ {
"id" : "1f8d42311349494785c630f6eb8a8602",
"name" : "Java"
} ],
"update_id" : null,
"is_support_cloudide" : true,
"has_notices" : false
} ]
} 状态码: 400
Bad Request
{
"error_code" : "TMDS.00001101",
"error_msg" : "非法参数"
} 状态码: 401
Unauthorized
{
"error_code" : "DEV.00000001",
"error_msg" : "未识别到用户认证信息"
} 状态码
| 状态码 | 描述 |
|---|---|
| 200 | ok |
| 400 | Bad Request |
| 401 | Unauthorized |
错误码
请参见错误码。