Member since
10-23-2015
1
Post
11
Kudos Received
0
Solutions
10-23-2015
07:18 PM
11 Kudos
Atlas API : Create Trait Type Traits are Atlas types that act like decorators to provide a
mechanism for classification. Traits can
be applied to any Atlas entities (instances of classes). An entity can have any number of traits. For example, a SECURITY_CLEARANCE trait could be defined with an
attribute ‘security_level’. An Atlas
entity (e.g. an instance of Person class) could be tagged with the
SECURITY_CLEARANCE trait by providing a value for the trait’s ‘security_level’
attribute. In order to use a trait, you first need to define the trait
type. You can do that by posting to the
Types resource of the Atlas REST APIs. Types Resource A type is the description of any representable item. In this case we are creating a trait type but
the same resource is used to represent enums, structs and classes as well. /types POST Submits a types definition containing a type definition
representing a trait. Request
Body Types
Definition application/json
Response
Body Types Response application/json
Types Definition Properties enumTypes : Array of Type
Definition for
ENUM types
structTypes : Array of Type
Definition for
STRUCT types
traitTypes : Array of Type
Definition for
TRAIT types
classTypes : Array of Type
Definition for
CLASS types
Type Definition Properties superTypes : Array of super type names.
hierarchicalMetaTypeName : String : The trait class name.
typeName : String : The type name.
attributeDefinitions : Array of Attribute Definition.
Attribute Definition Properties name : String : The attribute name.
dataTypeName : String : The owning data type name.
multiplicity : String : OPTIONAL, REQUIRED, COLLECTION, SET
isComposite : Boolean : True if the attribute’s lifecycle is dependent on the enclosing
type and is not just a reference.
isUnique : Boolean : True if the attribute must be unique.
isIndexable : Boolean : True if the attribute can be indexed.
reverseAttributeName : String : If this is a reference attribute, then the name of the attribute
on the Class that this refers to.
Types Response Properties requestId : String : The unique id for the request.
types : Array of Type Name Definition.
Type Name Definition Properties name : String : The type name.
Example The following example creates an Atlas trait type called
EXPIRES_ON that has a single attribute called ‘expiry_date’. POST http://c6401.ambari.apache.org:21000/api/atlas/types Body {
"enumTypes": [],
"structTypes": [],
"traitTypes": [
{
"superTypes":[],
"hierarchicalMetaTypeName":
"org.apache.atlas.typesystem.types.TraitType",
"typeName": "EXPIRES_ON",
"attributeDefinitions": [
{
"name": "expiry_date",
"dataTypeName": "date",
"multiplicity": "required",
"isComposite": false,
"isUnique": false,
"isIndexable": true,
"reverseAttributeName": null
}
]
}
],
"classTypes": []
} Response {
requestId:"qtp1796488937-14 - 1a194816-1c6f-451a-b706-6dc2f53139e5"
types:{
name:"EXPIRES_ON"
}
}
... View more
Labels: