如何使用API将分类列表插入Apache Atlas

2024-10-16 20:51:14 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用API将一组分类或标记插入ApacheAlas。 我面临一个错误

有人能帮我克服这个错误并插入分类吗。 我的代码:


import requests
import json
from requests.auth import HTTPBasicAuth
#specify url
url = 'http://aaaaa/api/atlas/v2/entity/classification'
print(url)
bulk = { "classification":{ "typeName":"Confidential","attributes":{ "retention_required":"true","max_retention_time_months":"12"}},"entityGuids":[ "be532571-1663-4550-af6d-28cfe39769f6"]}

#Call REST API
response = requests.put(url, data=bulk,auth=HTTPBasicAuth('xxx', 'yyy'))
print(response)
print(response.text)

此GUID有效

我面临的错误是:

<Response [500]>
There was an error processing your request. It has been logged (ID 7e31c72f5e0f5e3b).

简而言之,我希望通过python实现给定的屏幕功能

enter image description here

多谢各位


Tags: 标记importauthapiurlresponse错误分类
1条回答
网友
1楼 · 发布于 2024-10-16 20:51:14

将请求发送至:http://aaaaa/api/atlas/v2/types/typedefs

如果分类还不存在,您应该使用post,如果分类存在,您将得到409个客户端错误。 使用PUT更新现有分类

您的json应该如下所示:

{'classificationDefs: [{
            'entityTypes': entityTypes,
            'subTypes': subTypes,
            'superTypes': superTypes,
            'attributeDefs': attributeDefs,
            'category': category,
            'createdBy': createdBy,
            'description': description,
            'name': name,
            'options': options,
            'typeVersion': typeVersion,
            'updatedBy': updatedBy,
            'version': version
        }]
}

json中的属性类型:

列表:entityTypes、attributeDefs、超类型、子类型

字典:选项

编号:版本

rest是字符串或文本类型

相关问题 更多 >