Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Atlas create type via rest api

avatar
Master Guru

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".

1 ACCEPTED SOLUTION

avatar
@Sunile Manjee

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.

View solution in original post

4 REPLIES 4

avatar
@Sunile Manjee

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.

avatar
Master Guru

@Ayub Pathan Do I have to fatten the json string or will it accept the formatted version you posted?

avatar

@Sunile Manjee you can try as it is but either ways should be fine.

avatar
Master Guru

@Ayub Pathan i will try soon. trying 100s of ways last night and none of the combos worked. will update today.