更新时间:2024-04-28 GMT+08:00
分享

资产搜索(邀测)

功能介绍

资产搜索,该接口功能处于邀测阶段,后续将随功能公测将逐步开放。

调用方法

请参见如何调用API

URI

POST /v3/{project_id}/datamap/entities/search

表1 路径参数

参数

是否必选

参数类型

描述

project_id

String

项目ID,获取方法请参见项目ID和账号ID

最小长度:32

最大长度:36

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

X-Auth-Token

String

用户Token,使用Token认证时必选。通过调用IAM服务的“获取用户Token”接口获取响应消息头中X-Subject-Token的值。

最小长度:1

最大长度:65536

instance

String

实例ID,获取方法请参见实例ID和工作空间ID

最小长度:32

最大长度:36

表3 请求Body参数

参数

是否必选

参数类型

描述

query

String

查询关键字。

filter

DataMapFilterCriteria object

过滤条件对象。

facets

Array of strings

条件参数列表。

limit

Integer

分页显示每页返回结果数。默认值100。

offset

Integer

偏移量,默认值0。

relationship_attributes

Array of strings

关联关系属性。

sort

Array of Sort objects

排序信息。

owner

String

所有者。

query_privilege

Boolean

是否校验权限,默认值false。

表4 DataMapFilterCriteria

参数

是否必选

参数类型

描述

attribute

String

过滤属性维度。

枚举值:

  • base.DataAsset.sourceType 数据源类型

  • typeName 数据类型

  • classifications.name 分类

  • tags.name 标签

  • securityLevel.name 密级

  • workspaceId 空间

operator

String

操作标识符。

枚举值:

  • LT 小于

  • GT 大于

  • LTE 小于等于

  • GTE 大于等于

  • EQ 相等

  • NEQ 不相等

  • IN 在列表中

  • LIKE 任意模糊匹配

  • STARTS_WITH 起始相同匹配

  • ENDS_WITH 结束相同匹配

  • CONTAINS 包含

  • CONTAINS_ANY 包含任意

  • CONTAINS_ALL 包含所有

  • IS_NULL 为空

  • NOT_NULL 不为空

value

Array of strings

属性过滤值,根据attribute变化。如attribute为数据源:base.DataAsset.sourceType,则值可为["dws", "hive"]。

最小长度:1

最大长度:256

数组长度:1 - 20

condition

String

条件拼接准则。

枚举值:

  • OR 或者

  • AND 并且

criterion

Array of DataMapFilterCriteria objects

条件准则。

数组长度:1 - 10

表5 Sort

参数

是否必选

参数类型

描述

attribute

String

属性。

order

String

排序枚举值,默认值ASC。

枚举值:

  • DESC 降序

  • ASC 升序

响应参数

状态码: 200

表6 响应Body参数

参数

参数类型

描述

count

Number

查询结果总量。

entities

Array of Entity objects

资产实体列表。

facets

Array of objects

资产分类facets维度信息列表,数据结构List<Map<String, List<Aggregation>>> 取值为count。

metrics

Object

资产分类metrics维度信息列表,数据结构List<Map<String, List<Aggregation>>> 取值为aggregation。

referred_entities

Object

关联资产,数据类型Map<String, Entity>,key:guid,value:资产信息。

表7 Entity

参数

参数类型

描述

version

Number

数据版本。

relationship_attributes

Object

关联关系属性,数据类型Map<String, Object>,key:关系类型:value:关联关系对象。

super_type_names

Array of strings

父类资产类型。

business_attributes

Object

业务属性,数据类型Map<String, Map<String, Object>>,key:业务关系类型,value:业务关系。

multi_attributes

Object

承担密级和标签的多值对象数据结构,数据结构Map<String, List<Map<String, Object>>>,key:综合关系类型,value:综合关系。

privilege_info

EntityPrivilegeInfo object

实体特权信息。

extended_attributes

Object

拓展属性,数据结构Map<String, Object>,key:拓展属性,value:拓展属性值。

guid

String

资产guid。

type_name

String

资产类型名称。

type_display_name

String

类型展示名称。

display_text

String

展示名称。

attributes

Object

资产属性,Map<String, Object>。key:属性,value:属性值。

updated_attributes

Array of strings

修改属性列表。

project_id

String

项目id。

domain_id

String

主账号id。

instance_id

Array of strings

实例化id。

workspace_id

Array of strings

空间id列表。

status

String

状态。

created_by

String

创建人。

updated_by

String

修改人。

create_time

String

创建时间。

update_time

String

修改时间。

表8 EntityPrivilegeInfo

参数

参数类型

描述

privileges

Array of strings

特权列表。

inherit_privileges

Array of strings

继承特权列表。

状态码: 400

表9 响应Body参数

参数

参数类型

描述

error_code

String

错误码。

error_msg

String

错误描述。

状态码: 401

表10 响应Body参数

参数

参数类型

描述

error_code

String

错误码。

error_msg

String

错误描述。

状态码: 403

表11 响应Body参数

参数

参数类型

描述

error_code

String

错误码。

error_msg

String

错误描述。

状态码: 404

表12 响应Body参数

参数

参数类型

描述

error_code

String

错误码。

error_msg

String

错误描述。

状态码: 500

表13 响应Body参数

参数

参数类型

描述

error_code

String

错误码。

error_msg

String

错误描述。

请求示例

{
  "query" : "",
  "filter" : {
    "attribute" : null,
    "condition" : "AND",
    "criterion" : [ {
      "attribute" : null,
      "condition" : "OR",
      "criterion" : [ {
        "attribute" : "superTypeNames",
        "operator" : "IN",
        "value" : [ "dataasset.Database" ]
      }, {
        "attribute" : "typeName",
        "operator" : "IN",
        "value" : [ "dataasset.Database" ]
      } ]
    }, {
      "attribute" : "base.DataAsset.sourceType",
      "operator" : "IN",
      "value" : [ "dli" ]
    } ]
  },
  "facets" : [ "category.path", "typeName", "base.DataAsset.sourceType", "classifications.name", "tags.name", "securityLevel.name", "workspaceId", "base.Asset.catalogId" ],
  "limit" : 10,
  "offset" : 1,
  "sort" : [ {
    "attribute" : "createTime",
    "order" : "DESC"
  } ]
}

响应示例

状态码: 200

OK。

{
  "count" : 1234,
  "entities" : [ {
    "guid" : "a14d047e-3d67-4f71-90f0-53b6759a7fa5",
    "attributes" : {
      "owner" : "username",
      "is_favorite" : 0,
      "qualifiedName" : "dws@a96be22c-77f3-46ea-96ab-c8913052ec7d",
      "favorites_count" : 0,
      "description" : "This temp entity was generated from DLF lineage service",
      "clusterId" : "",
      "click_through" : 10,
      "baseType" : "Source",
      "path" : "",
      "catalogId" : "",
      "workspaceVsId" : { },
      "createTime" : "2022-12-09T01:59:42.319+00:00",
      "port" : 8000,
      "sourceType" : "dws",
      "name" : "dws_4autotest1_nomodify",
      "host" : "",
      "id" : "f9338475eb8c4cbda61b85c05908a432",
      "projectId" : ""
    },
    "status" : "ACTIVE",
    "version" : 0,
    "type_name" : "dataasset.Source",
    "type_display_name" : "数据源",
    "project_id" : 123456,
    "domain_id" : 123456,
    "instance_id" : [ "123456" ],
    "workspace_id" : [ "123456" ],
    "updated_by" : "username",
    "create_time" : "2023-05-17T06:32:00.511+00:00",
    "update_time" : "2023-05-17T06:32:00.511+00:00",
    "super_type_names" : [ "base.Asset", "base.Infrastructure" ],
    "business_attributes" : {
      "businessName" : {
        "confidence" : 1.0,
        "name" : "dws0505",
        "confirmed" : true
      }
    },
    "multi_attributes" : {
      "tags" : [ {
        "confidence" : 1.0,
        "name" : "个人数据误删",
        "confirmed" : false
      } ]
    },
    "privilege_info" : {
      "privileges" : [ ],
      "inherit_privileges" : [ ]
    },
    "extended_attributes" : { },
    "display_text" : "dws0505"
  } ],
  "facets" : [ {
    "typeName" : [ {
      "value" : "dataasset.Table",
      "id" : "dataasset.Table",
      "count" : 816,
      "aggregation" : 0.0,
      "children" : [ ]
    }, {
      "value" : "dlm.API",
      "id" : "dlm.API",
      "count" : 103,
      "aggregation" : 0.0,
      "children" : [ ]
    } ]
  }, {
    "base.DataAsset.sourceType" : [ {
      "value" : "dli",
      "id" : "dli",
      "count" : 1,
      "aggregation" : 0.0,
      "children" : [ ]
    }, {
      "value" : "hive",
      "id" : "hive",
      "count" : 1,
      "aggregation" : 0.0,
      "children" : [ ]
    } ]
  }, {
    "classifications.name" : [ {
      "value" : "01d1d582b14c4dfe8ebe53b15d88ffc2/c1549ae148144a37b219344892a5568f",
      "id" : "01d1d582b14c4dfe8ebe53b15d88ffc2/c1549ae148144a37b219344892a5568f",
      "count" : 2,
      "aggregation" : 0.0,
      "children" : [ ]
    }, {
      "value" : "01d1d582b14c4dfe8ebe53b15d88ffc2/e1893cd5baf34182b9d2e2728a02a2a8",
      "id" : "01d1d582b14c4dfe8ebe53b15d88ffc2/e1893cd5baf34182b9d2e2728a02a2a8",
      "count" : 2,
      "aggregation" : 0.0,
      "children" : [ ]
    } ]
  }, {
    "tags.name" : [ {
      "value" : "tag_testmLEi",
      "id" : "tag_testmLEi",
      "count" : 2,
      "aggregation" : 0.0,
      "children" : [ ]
    }, {
      "value" : "个人数据误删",
      "id" : "个人数据误删",
      "count" : 2,
      "aggregation" : 0.0,
      "children" : [ ]
    } ]
  }, {
    "securityLevel.name" : [ {
      "value" : "8a9480037c747038017c77363e510000",
      "id" : "8a9480037c747038017c77363e510000",
      "count" : 2,
      "aggregation" : 0.0,
      "children" : [ ]
    } ]
  }, {
    "workspaceId" : [ {
      "value" : "1b59d3c777ad4d619b89eeac4f3cce87",
      "id" : "1b59d3c777ad4d619b89eeac4f3cce87",
      "count" : 1234,
      "aggregation" : 0.0,
      "children" : [ ]
    } ]
  }, {
    "category.path" : [ {
      "value" : "ceshi_test",
      "id" : "eeb055e69c624311b6b9cfee89a4ec70/ceshi_test",
      "count" : 1234,
      "aggregation" : 0.0,
      "children" : [ ]
    }, {
      "value" : "交通",
      "id" : "1b59d3c777ad4d619b89eeac4f3cce87/交通",
      "count" : 1234,
      "aggregation" : 0.0,
      "children" : [ {
        "value" : "行程记录",
        "id" : "1b59d3c777ad4d619b89eeac4f3cce87/交通/行程记录",
        "count" : 1234,
        "aggregation" : 0.0,
        "children" : [ {
          "value" : "行程事实",
          "id" : "1b59d3c777ad4d619b89eeac4f3cce87/交通/行程记录/行程事实",
          "count" : 1234,
          "aggregation" : 0.0,
          "children" : [ ]
        } ]
      } ]
    } ]
  } ]
}

SDK代码示例

SDK代码示例如下。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.huaweicloud.sdk.test;

import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.dataartsstudio.v1.region.dataartsstudioRegion;
import com.huaweicloud.sdk.dataartsstudio.v1.*;
import com.huaweicloud.sdk.dataartsstudio.v1.model.*;


public class ShowDataSetsSolution {

    public static void main(String[] args) {
        // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
        // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
        String ak = System.getenv("CLOUD_SDK_AK");
        String sk = System.getenv("CLOUD_SDK_SK");
        String projectId = "{project_id}";

        ICredential auth = new BasicCredentials()
                .withProjectId(projectId)
                .withAk(ak)
                .withSk(sk);

        dataartsstudioClient client = dataartsstudioClient.newBuilder()
                .withCredential(auth)
                .withRegion(dataartsstudioRegion.valueOf("<YOUR REGION>"))
                .build();
        ShowDataSetsRequest request = new ShowDataSetsRequest();
        SearchParameter body = new SearchParameter();
        request.withBody(body);
        try {
            ShowDataSetsResponse response = client.showDataSets(request);
            System.out.println(response.toString());
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
            e.printStackTrace();
        } catch (ServiceResponseException e) {
            e.printStackTrace();
            System.out.println(e.getHttpStatusCode());
            System.out.println(e.getRequestId());
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
    }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# coding: utf-8

from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdataartsstudio.v1.region.dataartsstudio_region import dataartsstudioRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkdataartsstudio.v1 import *

if __name__ == "__main__":
    # The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    # In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak = __import__('os').getenv("CLOUD_SDK_AK")
    sk = __import__('os').getenv("CLOUD_SDK_SK")
    projectId = "{project_id}"

    credentials = BasicCredentials(ak, sk, projectId) \

    client = dataartsstudioClient.new_builder() \
        .with_credentials(credentials) \
        .with_region(dataartsstudioRegion.value_of("<YOUR REGION>")) \
        .build()

    try:
        request = ShowDataSetsRequest()
        request.body = SearchParameter(
        )
        response = client.show_data_sets(request)
        print(response)
    except exceptions.ClientRequestException as e:
        print(e.status_code)
        print(e.request_id)
        print(e.error_code)
        print(e.error_msg)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main

import (
	"fmt"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
    dataartsstudio "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1"
	"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1/model"
    region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dataartsstudio/v1/region"
)

func main() {
    // The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
    // In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
    ak := os.Getenv("CLOUD_SDK_AK")
    sk := os.Getenv("CLOUD_SDK_SK")
    projectId := "{project_id}"

    auth := basic.NewCredentialsBuilder().
        WithAk(ak).
        WithSk(sk).
        WithProjectId(projectId).
        Build()

    client := dataartsstudio.NewdataartsstudioClient(
        dataartsstudio.dataartsstudioClientBuilder().
            WithRegion(region.ValueOf("<YOUR REGION>")).
            WithCredential(auth).
            Build())

    request := &model.ShowDataSetsRequest{}
	request.Body = &model.SearchParameter{
	}
	response, err := client.ShowDataSets(request)
	if err == nil {
        fmt.Printf("%+v\n", response)
    } else {
        fmt.Println(err)
    }
}

更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。

状态码

状态码

描述

200

OK。

400

BadRequest。

401

Unauthorized。

403

Forbidden。

404

Not Found。

500

InternalServerError。

分享:

    相关文档

    相关产品