Get Asset Structure¶
获取资产所在的组织结构的上游组织结构。
操作权限¶
用户需要登录 Application Portal。
请求格式¶
GET https://{apigw-address}/app-portal-service/v2.2/asset/structure
请求参数(URI)¶
名称 | 位置(Path/Query) | 必需/可选 | 数据类型 | 描述 |
---|---|---|---|---|
assetId | Query | 必需 | String | 资产ID。如何获取Asset ID信息>> |
请求参数(Header)¶
名称 | 必需/可选 | 数据类型 | 描述 |
---|---|---|---|
Authorization | 必需 | String | Access Token,以Bearer Token表示,需要通过调用 Log In 或 Refresh Access Token 接口后获取。 |
响应参数¶
名称 | 数据类型 | 描述 |
---|---|---|
data | data结构体 | 组织结构。 |
data结构体¶
名称 | 数据类型 | 描述 |
---|---|---|
structures | AssetStructure结构体 | 组织结构树列表。 |
AssetStructure结构体¶
名称 | 数据类型 | 描述 |
---|---|---|
id | String | 组织结构ID。 |
name | String | 组织结构名称。 |
description | String | 组织描述。 |
orgId | String | 组织结构所在的组织ID。 |
children | AssetStructure结构体 | 下层组织结构。 |
错误码¶
代码 | 描述 |
---|---|
31400 | 资产ID不能为空 |
31401 | 提供的Access Token无效 |
31404 | 资产不存在 |
示例¶
请求示例¶
url: https://{apigw-address}/app-portal-service/v2.2/asset/structure?assetId=Dqp9GZsT
method: GET
headers: {"Authorization":"Bearer APP_PORTAL_S_TDKKeqfYBK3m5z3LRgKVqThWDYnRBN44"}
返回示例¶
{
"code": 0,
"data": {
"structures": [
{
"children": [],
"description": "",
"displayName": "wyf",
"id": "sg1566xxxxxxxxxx",
"name": "wyf",
"orgId": "yourOrgId"
}
]
},
"message": "OK"
}
Java SDK 调用示例¶
public class AppPortalSdkTest{
@Test
public void getAssetStructureTest() {
AssetStructureRequest assetStructureRequest = new AssetStructureRequest("your_asset_id", "your_access_token");
AssetStructureResponse assetStructureResponse = Poseidon.config(PConfig.init().appKey("your_access_key").appSecret("your_secret_key").debug())
.url("https://{apigw-address}").getResponse(assetStructureRequest, AssetStructureResponse.class);
System.out.println("Asset Structure res: " + JSON.toJSONString(assetStructureResponse));
assertNotNull("Response should not be null", assetStructureResponse);
assertNotNull("Response data should not be null", assetStructureResponse.data);
assertNotNull("Structure could not be null", assetStructureResponse.data.structures.size());
}
}