<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Example AtlasEntity REST API POST query in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/Example-AtlasEntity-REST-API-POST-query/m-p/222509#M184379</link>
    <description>&lt;P&gt;I'm posting this in case anyone finds it useful.&lt;/P&gt;&lt;P&gt;There's now a way for metamodels to inherit values from other values, but in 0.8 you can use the qualifiedName instead of the guid, which is much better.&lt;/P&gt;&lt;P&gt;Type&lt;/P&gt;&lt;P&gt;POST &lt;A href="http://127.0.0.1:21000/api/atlas/v2/types/typedefs" target="_blank"&gt;http://127.0.0.1:21000/api/atlas/v2/types/typedefs&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;{
   "enumDefs":[],
   "structDefs":[],
   "classificationDefs":[],
   "entityDefs":[
      {
         "superTypes":[
           "DataSet"
         ],
         "name":"test_entity_18",
         "description":"test_entity_18",
         "attributeDefs":[
            {
               "name":"test_18",
               "isOptional":true,
               "isUnique":true,
               "isIndexable":false,
               "typeName":"string",
               "valuesMaxCount":1,
               "cardinality":"SINGLE",
               "valuesMinCount":0
            },
           {
               "name":"test_18_db",
               "isOptional":true,
               "isUnique":true,
               "isIndexable":false,
               "typeName":"hive_db",
               "valuesMaxCount":1,
               "cardinality":"SINGLE",
               "valuesMinCount":0
            }
         ]
         
      }
   ]
}&lt;/PRE&gt;&lt;P&gt;Entity&lt;/P&gt;&lt;P&gt;POST &lt;A href="http://127.0.0.1:21000/api/atlas/v2/entity" target="_blank"&gt;http://127.0.0.1:21000/api/atlas/v2/entity&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;{
  "entity": {
    "typeName": "test_entity_18",
    "createdBy": "admin",
    "updatedBy": "admin",
    "attributes": {
      "description": "test decription",
      "name": "test_entity_18",
      "owner": "admin",
      "qualifiedName": "test_entity_18",
      "test_18": "attr1",
      "test_18_db": {
        "typeName": "hive_db",
          "uniqueAttributes": {
          "qualifiedName": "default@Sandbox"
      }
      }
    },
    "guid": -1
  },
  "referredEntities": {}
}&lt;/PRE&gt;&lt;P&gt;I learnt this from here - &lt;A href="https://issues.apache.org/jira/browse/ATLAS-1506" target="_blank"&gt;https://issues.apache.org/jira/browse/ATLAS-1506&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Jun 2017 15:17:03 GMT</pubDate>
    <dc:creator>laura_ngo</dc:creator>
    <dc:date>2017-06-28T15:17:03Z</dc:date>
    <item>
      <title>Example AtlasEntity REST API POST query</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Example-AtlasEntity-REST-API-POST-query/m-p/222503#M184373</link>
      <description>&lt;P&gt;Please could someone provide me with an example AtlasEntity REST API POST query I can use on my sandbox please. I'm struggling to post a successful one with v0.8.&lt;/P&gt;&lt;P&gt;I managed to create a type OK.  Here's my entity type. &lt;/P&gt;&lt;P&gt;POST &lt;A href="http://127.0.0.1:21000/api/atlas/v2/types/typedefs" target="_blank"&gt;http://127.0.0.1:21000/api/atlas/v2/types/typedefs&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;{
   "enumDefs":[],
   "structDefs":[],
   "classificationDefs":[],
   "entityDefs":[
      {
         "superTypes":[
           "DataSet"
         ],
         "name":"test_entity_7",
         "description":"test_entity_7",
         "createdBy": "admin",
         "updatedBy": "admin",
         "attributeDefs":[
            {
               "name":"test_7_1",
               "isOptional":true,
               "isUnique":false,
               "isIndexable":false,
               "typeName":"string",
               "valuesMaxCount":1,
               "cardinality":"SINGLE",
               "valuesMinCount":0
            },
           {
               "name":"test_7_2",
               "isOptional":true,
               "isUnique":false,
               "isIndexable":false,
               "typeName":"string",
               "valuesMaxCount":1,
               "cardinality":"SINGLE",
               "valuesMinCount":0
            }
         ]
         
      }
   ]
}

&lt;/PRE&gt;&lt;P&gt;I know the entity is supposed to be in this form, but could someone help me relate this back to my example type please? (I'm not a coder so I have to learn though examples.)&lt;/P&gt;&lt;P&gt;POST &lt;A href="http://127.0.0.1:21000/api/atlas/v2/entity" target="_blank"&gt;http://127.0.0.1:21000/api/atlas/v2/entity&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;{
  "entity" : {
    "guid" : "...",
    "status" : "ACTIVE",
    "createdBy" : "...",
    "updatedBy" : "...",
    "createTime" : 12345,
    "updateTime" : 12345,
    "version" : 12345,
    "classifications" : [ {
      "typeName" : "...",
      "attributes" : {
        "property1" : { },
        "property2" : { }
      }
    }, {
      "typeName" : "...",
      "attributes" : {
        "property1" : { },
        "property2" : { }
      }
    } ],
    "typeName" : "...",
    "attributes" : {
      "property1" : { },
      "property2" : { }
    }
  },
  "referredEntities" : {
    "property1" : {
      "guid" : "...",
      "status" : "ACTIVE",
      "createdBy" : "...",
      "updatedBy" : "...",
      "createTime" : 12345,
      "updateTime" : 12345,
      "version" : 12345,
      "classifications" : [ {
        "typeName" : "...",
        "attributes" : {
          "property1" : { },
          "property2" : { }
        }
      }, {
        "typeName" : "...",
        "attributes" : {
          "property1" : { },
          "property2" : { }
        }
      } ],
      "typeName" : "...",
      "attributes" : {
        "property1" : { },
        "property2" : { }
      }
    },
    "property2" : {
      "guid" : "...",
      "status" : "DELETED",
      "createdBy" : "...",
      "updatedBy" : "...",
      "createTime" : 12345,
      "updateTime" : 12345,
      "version" : 12345,
      "classifications" : [ {
        "typeName" : "...",
        "attributes" : {
          "property1" : { },
          "property2" : { }
        }
      }, {
        "typeName" : "...",
        "attributes" : {
          "property1" : { },
          "property2" : { }
        }
      } ],
      "typeName" : "...",
      "attributes" : {
        "property1" : { },
        "property2" : { }
      }
    }
  }
}
                
              

&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Jun 2017 23:19:01 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Example-AtlasEntity-REST-API-POST-query/m-p/222503#M184373</guid>
      <dc:creator>laura_ngo</dc:creator>
      <dc:date>2017-06-20T23:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: Example AtlasEntity REST API POST query</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Example-AtlasEntity-REST-API-POST-query/m-p/222504#M184374</link>
      <description>&lt;P&gt;Please try this:&lt;/P&gt;&lt;PRE&gt;{
  "entity": {
    "typeName": "test_entity_7",
    "attributes": {
      "description": "test decription",
      "name": "entity_name",
      "owner": "admin",
      "qualifiedName": "entity_name@cluster1",
      "test_7_1": "attr1",
      "test_7_2": "attr2"
    },
    "guid": -1
  },
  "referredEntities": {}
}
&lt;/PRE&gt;&lt;P&gt;The attribute list is little tricky when it comes to reading the class structure and then inferring the JSON serialization.&lt;/P&gt;&lt;P&gt;I copied the contents of the json above to &lt;EM&gt;atlasTypeCreation.json &lt;/EM&gt;file and then used the CURL command below:&lt;/P&gt;&lt;PRE&gt;curl -g -X POST -u admin:admin -H "Content-Type: application/json" -H "Cache-Control: no-cache" -d @/Users/amestry/Apache/docs/atlasTypeCreation.json &lt;A href="http://localhost:21000/api/atlas/v2/entity" target="_blank"&gt;http://localhost:21000/api/atlas/v2/entity&lt;/A&gt;
&lt;/PRE&gt;&lt;P&gt;Thanks @Sarath Subramanian for your help!&lt;/P&gt;</description>
      <pubDate>Wed, 21 Jun 2017 00:50:20 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Example-AtlasEntity-REST-API-POST-query/m-p/222504#M184374</guid>
      <dc:creator>amestry</dc:creator>
      <dc:date>2017-06-21T00:50:20Z</dc:date>
    </item>
    <item>
      <title>Re: Example AtlasEntity REST API POST query</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Example-AtlasEntity-REST-API-POST-query/m-p/222505#M184375</link>
      <description>&lt;P&gt;Thank you for you're help &lt;A rel="user" href="https://community.cloudera.com/users/14489/amestry.html" nodeid="14489"&gt;@Ashutosh Mestry&lt;/A&gt; and &lt;A rel="user" href="https://community.cloudera.com/users/12092/ssubramanian.html" nodeid="12092"&gt;@Sarath Subramanian&lt;/A&gt;. And apologies for the late response.&lt;/P&gt;&lt;P&gt;For anyone who is interested, here's what happened when I posted the entity.&lt;/P&gt;&lt;P&gt;Response:&lt;/P&gt;&lt;PRE&gt;{
"mutatedEntities": {
"CREATE": [  {
"typeName": "test_entity_7",
"attributes": {
"qualifiedName": "test_entity_7_hw@Sandbox"
}
,
"guid": "01960675-149f-43da-bdb8-da79058beb51",
"status": "ACTIVE"
}
],
}
,
"guidAssignments": {
-1: "01960675-149f-43da-bdb8-da79058beb51"
}
}&lt;/PRE&gt;&lt;P&gt;GET &lt;A href="http://127.0.0.1:21000/api/atlas/v2/entity/guid/01960675-149f-43da-bdb8-da79058beb51" target="_blank"&gt;http://127.0.0.1:21000/api/atlas/v2/entity/guid/01960675-149f-43da-bdb8-da79058beb51&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;{
"referredEntities": {
}
,
"entity": {
"typeName": "test_entity_7",
"attributes": {
"owner": "admin",
"test_7_2": "attr2",
"test_7_1": "attr1",
"qualifiedName": "test_entity_7_hw@Sandbox",
"name": "test_entity_7_hw",
"description": "test decription"
}
,

"guid": "01960675-149f-43da-bdb8-da79058beb51",
"status": "ACTIVE",
"createdBy": "holger_gov",
"updatedBy": "holger_gov",
"createTime": 1498267676098,
"updateTime": 1498267676098,
"version": 0,
"classifications": [],
}


}
&lt;/PRE&gt;&lt;P&gt;I'm just testing in a sandbox and using Chrome apps 'Advanced REST client'. Is this why createdBy and updatedBy is set to holger_gov?&lt;/P&gt;&lt;P&gt;If I set the createdBy and updatedBy I still get the holger_gov:&lt;/P&gt;&lt;P&gt;POST &lt;A href="http://127.0.0.1:21000/api/atlas/v2/entity" target="_blank"&gt;http://127.0.0.1:21000/api/atlas/v2/entity&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;{
  "entity": {
    "typeName": "test_entity_7",
    "createdBy": "admin",
    "updatedBy": "admin",
    "attributes": {
      "description": "test decription",
      "name": "test_entity_7_hw_admin",
      "owner": "admin",
      "qualifiedName": "test_entity_7_hw_admin@Sandbox",
      "test_7_1": "attr1",
      "test_7_2": "attr2"
    },
    "guid": -1
  },
  "referredEntities": {}
}
&lt;/PRE&gt;&lt;P&gt;Response&lt;/P&gt;&lt;PRE&gt;{
"mutatedEntities": {
"CREATE": [  {
"typeName": "test_entity_7",
"attributes": {
"qualifiedName": "test_entity_7_hw_admin@Sandbox"
}
,
"guid": "ed9cf696-cd76-4814-a407-9fdb8d18da3c",
"status": "ACTIVE"
}
],
}
,
"guidAssignments": {
-1: "ed9cf696-cd76-4814-a407-9fdb8d18da3c"
}
}
&lt;/PRE&gt;&lt;P&gt;GET &lt;A href="http://127.0.0.1:21000/api/atlas/v2/entity/guid/ed9cf696-cd76-4814-a407-9fdb8d18da3c" target="_blank"&gt;http://127.0.0.1:21000/api/atlas/v2/entity/guid/ed9cf696-cd76-4814-a407-9fdb8d18da3c&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;{
"referredEntities": {
}
,
"entity": {
"typeName": "test_entity_7",
"attributes": {
"owner": "admin",
"test_7_2": "attr2",
"test_7_1": "attr1",
"qualifiedName": "test_entity_7_hw_admin@Sandbox",
"name": "test_entity_7_hw_admin",
"description": "test decription"
}
,
"guid": "ed9cf696-cd76-4814-a407-9fdb8d18da3c",
"status": "ACTIVE",
"createdBy": "holger_gov",
"updatedBy": "holger_gov",
"createTime": 1498268595794,
"updateTime": 1498268595794,
"version": 0,
"classifications": [],
}
}
&lt;/PRE&gt;&lt;P&gt;Also, how do I use /v2/entity/bulk? I get the following error:  &lt;/P&gt;&lt;PRE&gt;{
"errorCode": "ATLAS-404-00-005",
"errorMessage": "Given instance guid {0} is invalid/not found"
}
&lt;/PRE&gt;&lt;P&gt;I currently can't find a way of returning the GET for an attribute without first copying the guid when I first create it!!!&lt;/P&gt;</description>
      <pubDate>Sun, 25 Jun 2017 22:31:42 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Example-AtlasEntity-REST-API-POST-query/m-p/222505#M184375</guid>
      <dc:creator>laura_ngo</dc:creator>
      <dc:date>2017-06-25T22:31:42Z</dc:date>
    </item>
    <item>
      <title>Re: Example AtlasEntity REST API POST query</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Example-AtlasEntity-REST-API-POST-query/m-p/222506#M184376</link>
      <description>&lt;P&gt;The &lt;EM&gt;bulk&lt;/EM&gt; REST APIs allow for working on several entities in a single call. They are useful when calling Atlas programmatically as this lead to less chatty interaction.&lt;/P&gt;&lt;P&gt;To answer the question above, the bulk GET call would be like this:&lt;/P&gt;&lt;PRE&gt;curl -g -X GET -u admin:admin "http://localhost:21000/api/atlas/v2/entity/bulk?guid=50ffa975-294d-4996-97c0-414368c67ffc&amp;amp;guid=fb47ab8a-b908-465d-b8f7-3ab5bbb44881"  -H 'Content-Type: application/json' &amp;gt; testOutput.json&lt;/PRE&gt;&lt;P&gt;After formatting the &lt;EM&gt;testOutput.json, &lt;/EM&gt;you will see the details of the entity.&lt;/P&gt;&lt;P&gt;The bulk calls takes a list of strings, which is relatively easy to hand code. Others take more complex types, which will take more effort to hand code the json, hence easier to use via program.&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 00:14:51 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Example-AtlasEntity-REST-API-POST-query/m-p/222506#M184376</guid>
      <dc:creator>amestry</dc:creator>
      <dc:date>2017-06-26T00:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: Example AtlasEntity REST API POST query</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Example-AtlasEntity-REST-API-POST-query/m-p/222507#M184377</link>
      <description>&lt;P&gt;Thank you, that helps enormously! &lt;/P&gt;&lt;P&gt;I'm obviously doing something wrong with the GET /v2/entity/uniqueAttribute/type/{typeName}&lt;/P&gt;&lt;P&gt;I created an entityDefs type called test_entity_15. I then created an entity called test_entity_15.&lt;/P&gt;&lt;PRE&gt;{
   "enumDefs":[],
   "structDefs":[],
   "classificationDefs":[],
   "entityDefs":[
      {
         "superTypes":[
           "DataSet"
         ],
         "name":"test_entity_15",
         "description":"test_entity_15",
         "attributeDefs":[
            {
               "name":"test_15_1",
               "isOptional":true,
               "isUnique":true,
               "isIndexable":false,
               "typeName":"string",
               "valuesMaxCount":1,
               "cardinality":"SINGLE",
               "valuesMinCount":0
            }
         ]
         
      }
   ]
}&lt;/PRE&gt;&lt;PRE&gt;{
  "entity": {
    "typeName": "test_entity_15",
    "attributes": {
      "description": "test_entity_15",
      "name": "test_entity_15_1",
      "owner": "admin",
      "qualifiedName": "test_entity_15@Sandbox",
      "test_15_1": "attr1"
    },
    "guid": -1
  },
  "referredEntities": {}
}&lt;/PRE&gt;&lt;P&gt;But when I try GET &lt;A href="http://127.0.0.1:21000/api/atlas/v2/entity/uniqueAttribute/type/test_entity_15" target="_blank"&gt;http://127.0.0.1:21000/api/atlas/v2/entity/uniqueAttribute/type/test_entity_15&lt;/A&gt; I get this error.&lt;/P&gt;&lt;PRE&gt;{
"errorCode": "ATLAS-400-00-013",
"errorMessage": "Type test_entity_15 with unique attribute does not exist"
}
&lt;/PRE&gt;&lt;P&gt;I set "isUnique" to true, so I'm not sure what else is preventing the unique attribute!&lt;/P&gt;&lt;P&gt;Also, I created a JIRA due to the createdBy and updatedBy inconsistency between type and entity POSTs- &lt;A href="https://issues.apache.org/jira/browse/ATLAS-1895" target="_blank"&gt;https://issues.apache.org/jira/browse/ATLAS-1895&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 02:58:37 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Example-AtlasEntity-REST-API-POST-query/m-p/222507#M184377</guid>
      <dc:creator>laura_ngo</dc:creator>
      <dc:date>2017-06-26T02:58:37Z</dc:date>
    </item>
    <item>
      <title>Re: Example AtlasEntity REST API POST query</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Example-AtlasEntity-REST-API-POST-query/m-p/222508#M184378</link>
      <description>&lt;P&gt;This worked fine:&lt;/P&gt;&lt;PRE&gt;curl -g -X GET -u admin:admin "http://localhost:21000/api/atlas/v2/entity/bulk?guid=4762daa1-ac15-4b57-afbc-2ddfa063e1f5"  -H 'Content-Type: application/json'&lt;/PRE&gt;&lt;P&gt;The guid belongs to the newly created entity. Which means the entity was created successfully.&lt;/P&gt;&lt;P&gt;Now to retrieve the entity with uniqueAttribute it needs additional information. This call does the trick:&lt;/P&gt;&lt;PRE&gt;curl -g -X GET -u admin:admin "http://localhost:21000/api/atlas/v2/entity/uniqueAttribute/type/test_entity_15?attr:qualifiedName=test_entity_15@Sandbox" -H 'Content-Type: application/json&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Jun 2017 22:28:05 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Example-AtlasEntity-REST-API-POST-query/m-p/222508#M184378</guid>
      <dc:creator>amestry</dc:creator>
      <dc:date>2017-06-26T22:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: Example AtlasEntity REST API POST query</title>
      <link>https://community.cloudera.com/t5/Support-Questions/Example-AtlasEntity-REST-API-POST-query/m-p/222509#M184379</link>
      <description>&lt;P&gt;I'm posting this in case anyone finds it useful.&lt;/P&gt;&lt;P&gt;There's now a way for metamodels to inherit values from other values, but in 0.8 you can use the qualifiedName instead of the guid, which is much better.&lt;/P&gt;&lt;P&gt;Type&lt;/P&gt;&lt;P&gt;POST &lt;A href="http://127.0.0.1:21000/api/atlas/v2/types/typedefs" target="_blank"&gt;http://127.0.0.1:21000/api/atlas/v2/types/typedefs&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;{
   "enumDefs":[],
   "structDefs":[],
   "classificationDefs":[],
   "entityDefs":[
      {
         "superTypes":[
           "DataSet"
         ],
         "name":"test_entity_18",
         "description":"test_entity_18",
         "attributeDefs":[
            {
               "name":"test_18",
               "isOptional":true,
               "isUnique":true,
               "isIndexable":false,
               "typeName":"string",
               "valuesMaxCount":1,
               "cardinality":"SINGLE",
               "valuesMinCount":0
            },
           {
               "name":"test_18_db",
               "isOptional":true,
               "isUnique":true,
               "isIndexable":false,
               "typeName":"hive_db",
               "valuesMaxCount":1,
               "cardinality":"SINGLE",
               "valuesMinCount":0
            }
         ]
         
      }
   ]
}&lt;/PRE&gt;&lt;P&gt;Entity&lt;/P&gt;&lt;P&gt;POST &lt;A href="http://127.0.0.1:21000/api/atlas/v2/entity" target="_blank"&gt;http://127.0.0.1:21000/api/atlas/v2/entity&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;{
  "entity": {
    "typeName": "test_entity_18",
    "createdBy": "admin",
    "updatedBy": "admin",
    "attributes": {
      "description": "test decription",
      "name": "test_entity_18",
      "owner": "admin",
      "qualifiedName": "test_entity_18",
      "test_18": "attr1",
      "test_18_db": {
        "typeName": "hive_db",
          "uniqueAttributes": {
          "qualifiedName": "default@Sandbox"
      }
      }
    },
    "guid": -1
  },
  "referredEntities": {}
}&lt;/PRE&gt;&lt;P&gt;I learnt this from here - &lt;A href="https://issues.apache.org/jira/browse/ATLAS-1506" target="_blank"&gt;https://issues.apache.org/jira/browse/ATLAS-1506&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2017 15:17:03 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/Example-AtlasEntity-REST-API-POST-query/m-p/222509#M184379</guid>
      <dc:creator>laura_ngo</dc:creator>
      <dc:date>2017-06-28T15:17:03Z</dc:date>
    </item>
  </channel>
</rss>

