创建或修改资产(邀测)
功能介绍
创建或修改资产,该接口功能处于邀测阶段,后续将随功能公测将逐步开放。
调用方法
请参见如何调用API。
URI
POST /v1/{project_id}/datamap/entities
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
项目ID,获取方法请参见项目ID和账号ID。 |
请求参数
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
X-Auth-Token |
是 |
String |
用户Token,使用Token认证时必选。通过调用IAM服务的“获取用户Token”接口获取响应消息头中X-Subject-Token的值。 |
instance |
是 |
String |
实例ID,获取方法请参见实例ID和工作空间ID。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
entity |
否 |
Entity object |
资产信息。 |
referred_entities |
否 |
Object |
关联资产信息,结构体Map<String, Entity>。key:资产guid,value:资产信息。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
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 |
修改时间。 |
响应参数
状态码: 400
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
错误码。 |
error_msg |
String |
错误描述。 |
状态码: 401
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
错误码。 |
error_msg |
String |
错误描述。 |
状态码: 403
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
错误码。 |
error_msg |
String |
错误描述。 |
状态码: 404
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
错误码。 |
error_msg |
String |
错误描述。 |
状态码: 500
参数 |
参数类型 |
描述 |
---|---|---|
error_code |
String |
错误码。 |
error_msg |
String |
错误描述。 |
请求示例
{ "entity" : { "guid" : -1, "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" : 0, "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" : 0, "update_time" : 0, "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" }, "referred_entities" : null }
响应示例
无
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 CreateOrUpdateEntitiesSolution { 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(); CreateOrUpdateEntitiesRequest request = new CreateOrUpdateEntitiesRequest(); DataEntityWithExtInfo body = new DataEntityWithExtInfo(); request.withBody(body); try { CreateOrUpdateEntitiesResponse response = client.createOrUpdateEntities(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 33 |
# coding: utf-8 import os 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 = os.environ["CLOUD_SDK_AK"] sk = os.environ["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 = CreateOrUpdateEntitiesRequest() request.body = DataEntityWithExtInfo( ) response = client.create_or_update_entities(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.CreateOrUpdateEntitiesRequest{} request.Body = &model.DataEntityWithExtInfo{ } response, err := client.CreateOrUpdateEntities(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。 |