更新时间:2023-06-26 GMT+08:00

获取应用所有组件

功能介绍

通过此API获取应用下所有应用组件。

URI

GET /v2/{project_id}/cas/applications/{application_id}/components

表1 路径参数

参数

参数类型

必选

描述

project_id

String

租户项目ID

application_id

String

应用ID

表2 查询参数

参数

参数类型

必选

描述

limit

String

指定个数,取值[0, 100]或者1000,指定的值不在该范围内的话相当于赋值为10。默认1000,用于不分页的场景。分页的场景取值请用[0, 100]。

offset

String

指定偏移量。

order_by

String

排序字段,默认按创建时间排序。

排序字段支持枚举值:create_time、name、update_time。

order

String

desc/asc,默认desc。

请求消息

响应消息

表3 响应参数

参数

参数类型

描述

count

Integer

组件总数。

components

Array of objects

组件参数,请参考表4

表4 components参数

参数

参数类型

描述

id

String

应用组件ID。

name

String

应用组件名称。

status

integer

取值0或1。

0:表示正常状态。

1:表示正在删除。

runtime

String

运行时。

category

String

应用组件类型如:Webapp、MicroService、Common。

sub_category

String

应用组件子类型。

Webapp的子类型有Web。

MicroService的子类型有Java Chassis、Go Chassis、Mesher、Spring Cloud、Dubbo。

Common的子类型可以为空。

application_id

String

应用ID。

source

Object

代码/软件包来源,请参考表5

description

String

描述。

creator

String

创建人。

create_time

Integer

创建时间。

update_time

Integer

修改时间。

表5 source参数

参数

参数类型

描述

kind

String

类型,支持源码code和artifact软件包。

spec

Object

对应code请参考表6;对应artifact请参考表7

表6 code spec参数

参数

参数类型

描述

repo_type

String

代码仓类型,支持GitHub、GitLab、Gitee、Bitbucket

repo_url

String

代码仓url,如:https://github.com/example/demo.git

repo_ref

String

代码分支或者Tag,默认是master

repo_auth

String

授权名称,在授权列表获取

表7 artifact specc参数

参数

参数类型

描述

storage

String

存储方式

type

String

类别

url

String

软件包地址

auth

String

认证方式

properties

Object

软件包的其他属性,只有在选择对象存储obs的时候才需要添加。参考表8

表8 artifact spec properties参数

参数

参数类型

描述

endpoint

String

obs的终端地址,比如:https://obs.region_name.external_domain_name.com

bucket

String

软件包在obs的桶名

key

String

obs桶中的对象,一般是软件包名,有文件夹的话要加上文件夹的路径。比如test.jar或者demo/test.jar

示例

请求示例

响应示例
{
    "components": [
       {
	"id": "384eb8d4-c193-4d84-9558-6fda2366b536",
	"name": "mycomponent",
	"runtime": "Java8",
	"category": "MicroService",
	"sub_category": "Java Chassis",
	"description": "",
	"project_id": "384eb8d4-c193-4d84-9558-6fda23698536",
	"application_id": "a8f7eed5-0aa0-4251-9723-c9119a6bf56d",
        "source": {
		"kind": "artifact",
		"spec": {
			"storage": "obs",
			"type": "package",
			"url": "obs://myapp/demo.jar",
			"properties": {
				"bucket": "myapp",
				"key": "demo.jar",
				"endpoint": "https://obs.region_id.external_domain_name.com"
			}
		}
	},
	"build": {
		"id": "w3dpv7p0t1vpxvey5hjb22iuwxway1vupwx0nae1",
		"parameters": {
			"artifact_namespace": "ns",
			"use_public_cluster": true
		}
	},
	"pipeline_ids": null,
	"status": 0,
	"creator": "xxx",
	"create_time": 1610333934288,
	"update_time": 1610333934288
       }
    ], 
    "count": 1
}

状态码

表9 状态码说明

状态码

描述

200

操作成功

400

错误的请求

404

请求对象不存在

500

内部错误

错误码

错误码格式为:SVCSTG.00100.[Error_ID],例如:SVCSTG.00100400。错误码说明请参考应用管理API错误码