有人使用curl和V2 REST API成功更新了Apache Atlas中的类型吗?
例如:我会尝试将字段添加到rdbms_table类型,例如:
{
"name": "business_contact_info",
"typeName": "string",
"isOptional": true,
"cardinality": "SINGLE",
"valuesMinCount": 0,
"valuesMaxCount": 1,
"isUnique": false,
"isIndexable": false,
"includeInNotification": false
}
我围绕此命令尝试了几种解决方案:
curl -u username:password -d @./typedef-rdbms_table.json -X PUT http://c7402.ambari.apache.org:21000/api/atlas/v2/types/typedefs -H ‘Content-Type:application/json; charset=UTF-8’
带有一个看起来像json文件:
{
"classificationDefs" : [],
"entityDefs": [
{
"category": "ENTITY",
"guid": "ef3d3dd6-c2ac-4f0b-a566-9b8036c3b03b",
"createdBy": "atlas",
"updatedBy": "atlas",
"createTime": 1541616267291,
"updateTime": 1541616267291,
"version": 1,
"name": "rdbms_table",
"description": "a table in an rdbms database (schema)",
"typeVersion": "1.0",
"attributeDefs": [
{
"name": "db",
"typeName": "rdbms_db",
"isOptional": true,
"cardinality": "SINGLE",
"valuesMinCount": 0,
"valuesMaxCount": 1,
"isUnique": false,
"isIndexable": false,
"includeInNotification": false,
"constraints": [
{
"type": "inverseRef",
"params": {
"attribute": "tables"
}
}
]
},
{
"name": "name_path",
"typeName": "string",
"isOptional": true,
"cardinality": "SINGLE",
"valuesMinCount": 0,
"valuesMaxCount": 1,
"isUnique": false,
"isIndexable": false,
"includeInNotification": false
},
{
"name": "createTime",
"typeName": "date",
"isOptional": true,
"cardinality": "SINGLE",
"valuesMinCount": 0,
"valuesMaxCount": 1,
"isUnique": false,
"isIndexable": false,
"includeInNotification": false
},
{
"name": "comment",
"typeName": "string",
"isOptional": true,
"cardinality": "SINGLE",
"valuesMinCount": 0,
"valuesMaxCount": 1,
"isUnique": false,
"isIndexable": false,
"includeInNotification": false
},
{
"name": "type",
"typeName": "string",
"isOptional": true,
"cardinality": "SINGLE",
"valuesMinCount": 0,
"valuesMaxCount": 1,
"isUnique": false,
"isIndexable": false,
"includeInNotification": false
},
{
"name": "contact_info",
"typeName": "string",
"isOptional": true,
"cardinality": "SINGLE",
"valuesMinCount": 0,
"valuesMaxCount": 1,
"isUnique": false,
"isIndexable": false,
"includeInNotification": false
},
{
"name": "business_contact_info",
"typeName": "string",
"isOptional": true,
"cardinality": "SINGLE",
"valuesMinCount": 0,
"valuesMaxCount": 1,
"isUnique": false,
"isIndexable": false,
"includeInNotification": false
},
{
"name": "quality_kpi",
"typeName": "int",
"isOptional": true,
"cardinality": "SINGLE",
"valuesMinCount": 0,
"valuesMaxCount": 1,
"isUnique": false,
"isIndexable": false,
"includeInNotification": false
},
{
"name": "business_name",
"typeName": "string",
"isOptional": true,
"cardinality": "SINGLE",
"valuesMinCount": 0,
"valuesMaxCount": 1,
"isUnique": false,
"isIndexable": false,
"includeInNotification": false
},
{
"name": "columns",
"typeName": "array<rdbms_column>",
"isOptional": true,
"cardinality": "SET",
"valuesMinCount": 0,
"valuesMaxCount": 2147483647,
"isUnique": false,
"isIndexable": false,
"includeInNotification": false,
"constraints": [
{
"type": "ownedRef"
}
]
},
{
"name": "indexes",
"typeName": "array<rdbms_index>",
"isOptional": true,
"cardinality": "SET",
"valuesMinCount": 0,
"valuesMaxCount": 2147483647,
"isUnique": false,
"isIndexable": false,
"includeInNotification": false,
"constraints": [
{
"type": "ownedRef"
}
]
},
{
"name": "foreign_keys",
"typeName": "array<rdbms_foreign_key>",
"isOptional": true,
"cardinality": "SET",
"valuesMinCount": 0,
"valuesMaxCount": 2147483647,
"isUnique": false,
"isIndexable": false,
"includeInNotification": false,
"constraints": [
{
"type": "ownedRef"
}
]
}
],
"superTypes": [
"DataSet",
"Asset"
],
"subTypes": []
}
],
"enumDefs" : [],
"relationshipDefs" : [],
"structDefs" : []
}
谢谢!
答案 0 :(得分:0)
Apache Atlas允许使用可选属性更新typeDef。 创建和更新类型定义可以通过以下方式完成:
初始typeDef: POST:/ api / atlas / v2 / types / typedefs
{
"entityDefs": [
{
"name": "test",
"description": "test type",
"superTypes": [
"DataSet"
],
"typeVersion": "1.0",
"attributeDefs": [
{
"name": "subject_area_name",
"typeName": "string",
"isOptional": true,
"cardinality": "SINGLE",
"isUnique": false,
"isIndexable": true
}
]
}
]
}
添加可选属性:
{
"name": "subject_area_id",
"typeName": "string",
"isOptional": true,
"cardinality": "SINGLE",
"isUnique": false,
"isIndexable": true
}
输入:/ api / atlas / v2 / types / typedefs
{
"enumDefs": [],
"structDefs": [],
"classificationDefs": [],
"entityDefs": [
{
"category": "ENTITY",
"guid": "d711c846-06a4-4965-b490-f603e16ca29e",
"createdBy": "admin",
"updatedBy": "admin",
"createTime": 1549344291502,
"updateTime": 1549344291502,
"version": 1,
"name": "test",
"description": "test type",
"typeVersion": "1.0",
"attributeDefs": [
{
"name": "subject_area_id",
"typeName": "string",
"isOptional": true,
"cardinality": "SINGLE",
"isUnique": false,
"isIndexable": true
},
{
"name": "subject_area_name",
"typeName": "string",
"isOptional": true,
"cardinality": "SINGLE",
"valuesMinCount": 0,
"valuesMaxCount": 1,
"isUnique": false,
"isIndexable": true,
"includeInNotification": false
}
],
"superTypes": [
"DataSet"
],
"subTypes": []
}
],
"relationshipDefs": []
}
这将使用附加属性更新类型。 Detailed REST documentaion can be found here