Created 08-23-2016 04:48 AM
How to create new atlas Type using rest api? information on the apache site is lite. A working example would be extremely helpful. for example i want to create type call "MyNewType".
Created 08-23-2016 11:00 AM
Below is an example to create type.
Save below json to some file(example type.json)
{
"enumTypes": [
],
"structTypes": [
],
"traitTypes": [
],
"classTypes": [
{
"superTypes": [
],
"hierarchicalMetaTypeName": "org.apache.atlas.typesystem.types.ClassType",
"typeName": "myNewType1",
"typeDescription": null,
"attributeDefinitions": [
{
"name": "multiplicityRequired",
"dataTypeName": "string",
"multiplicity": "required",
"isComposite": true,
"isUnique": true,
"isIndexable": true,
"reverseAttributeName": null
}
]
}
]
}
Submit HTTP POST request to atlas to create a type of above.
Command:
curl -X POST -d @type.json -u <username>:<password> -H 'Content-Type: application/json; charset=UTF-8' http(s)://<atlas-hostname>:<atlas-port>/api/atlas/types
Output:
{"requestId":"qtp513700442-26 - b84cee5b-7940-4308-a35b-fc9af5de0b81","types":[{"name":"myNewType1"}]}
Please refer to this post for more information: https://community.hortonworks.com/content/kbentry/124/atlas-api-tips-create-trait-type-example.html
Hope this helps.
Created 08-23-2016 11:00 AM
Below is an example to create type.
Save below json to some file(example type.json)
{
"enumTypes": [
],
"structTypes": [
],
"traitTypes": [
],
"classTypes": [
{
"superTypes": [
],
"hierarchicalMetaTypeName": "org.apache.atlas.typesystem.types.ClassType",
"typeName": "myNewType1",
"typeDescription": null,
"attributeDefinitions": [
{
"name": "multiplicityRequired",
"dataTypeName": "string",
"multiplicity": "required",
"isComposite": true,
"isUnique": true,
"isIndexable": true,
"reverseAttributeName": null
}
]
}
]
}
Submit HTTP POST request to atlas to create a type of above.
Command:
curl -X POST -d @type.json -u <username>:<password> -H 'Content-Type: application/json; charset=UTF-8' http(s)://<atlas-hostname>:<atlas-port>/api/atlas/types
Output:
{"requestId":"qtp513700442-26 - b84cee5b-7940-4308-a35b-fc9af5de0b81","types":[{"name":"myNewType1"}]}
Please refer to this post for more information: https://community.hortonworks.com/content/kbentry/124/atlas-api-tips-create-trait-type-example.html
Hope this helps.
Created 08-23-2016 03:42 PM
@Ayub Pathan Do I have to fatten the json string or will it accept the formatted version you posted?
Created 08-23-2016 03:59 PM
@Sunile Manjee you can try as it is but either ways should be fine.
Created 08-23-2016 04:30 PM
@Ayub Pathan i will try soon. trying 100s of ways last night and none of the combos worked. will update today.