使用v2 API的apache图集更新类型



有人成功地使用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" : []
}

谢谢!

Apache Atlas允许使用可选属性更新typeDef。创建和更新类型定义可以通过以下方式完成:

初始类型Def: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
}

PUT:/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": []
}

这将更新具有附加属性的类型。详细的REST文档可以在这里找到

相关内容

  • 没有找到相关文章

最新更新