Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

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.