Thank you for the info Madhan. Was actually using the "api/atlas/v2/relationship" endpoint, but guess I did not copy-pate that part in the original message. Could you point me to the docs that specify what a valid AtlasRelationshipDef string is (have never used Atlas before)? Found https://atlas.apache.org/api/v2/json_AtlasRelationshipDef.html, but its a bit confusing how I am supposed to incorporate this info in the context of what you have told me. It talks about RelationshipDefs as objects and you are saying that I need to put a valid name of one in the relationship creation API call, so from my interpretation these 2 bits of information are circular (need to already have some blank RelationshipDef to assign to a Relationship creation call). Could you clarify what I'm getting wrong here? Do you know of any other resource for understanding the API (as the endpoint mistake was from just following the docs and the docs don't appear to specify which fields are optional or what they relate to)? Thanks again.
On Sat, Aug 10, 2019 at 7:24 AM Madhan Neethiraj <[email protected]> wrote: > Here is an example of REST API call to create relationship between 2 > entities: > > > > POST api/atlas/v2/relationship > > { > > "typeName": "*<relationshipType>*", > > "end1": { > > "guid": "<*guid of entity at end1>*" > > }, > > "end2": { > > "guid": "<*guid of entity at end2>*" > > } > > } > > > > All other fields are optional. > > > > Comparing your example, here are couple of issues to fix: > > 1. incorrect URI to the API: “api/atlas” missing in the path > 2. typeName for the relationship should be name of a > AtlasRelationshipDef; the value provided, "hdfs_path", is an AtlasEntityDef > > > > Hope this helps. > > > > Madhan > > > > *From: *Reed Villanueva <[email protected]> > *Reply-To: *"[email protected]" <[email protected]> > *Date: *Friday, August 9, 2019 at 7:25 PM > *To: *"[email protected]" <[email protected]> > *Subject: *Simple example for adding relationships between Atlas entities? > > > > What is the correct way to use the REST API to add a relationship between > entities in apache atlas? Looking at the docs > <https://atlas.apache.org/api/v2/resource_RelationshipREST.html> for the > REST API, I find it difficult to tell what some of the fields mean, which > are required or not (and what happens if they are not entered), or what > default values should be (since the examples use what appear to be > placeholder values (eg. what is provenanceType or the homeId field?)). > > Could someone provide any example of what this would look like in real / > valid values? Eg. if had 2 entities E1 and E2 already added to Atlas and > wanted to establish a relationship between the two, would want to do > something like... > > curl -X POST --header 'Content-Type: application/json;charset=UTF-8' --header > 'Accept: application/json' -d '{<simplified json>}' > 'https://atlas-server-hostname:21000/v2/relationship' > > Trying > > [hph_etl@HW03 ~]$ curl -vv -u admin:admin -X POST --header 'Content-Type: > application/json;charset=UTF-8' --header 'Accept: application/json' -d '{ \ > > "createTime": 1565135406, \ > > "createdBy": "hph_etl", \ > > "end1": { \ > > "guid": "2ddcda5b-2489-4636-a9ab-12b199c02422", \ > > "typeName": "hdfs_path" \ > > }, \ > > "end2": { \ > > "guid": "a33f45de-13d0-4a30-9df7-b0e02eb0dfd5", \ > > "typeName": "hdfs_path" \ > > }, \ > > "guid": "2ddcda5b-2489-4636-a9ab-12b199c02422", \ > > "propagateTags": "TWO_TO_ONE", \ > > "status": "ACTIVE", \ > > "typeName": "hdfs_path" \ > > }' 'http://HW03.co.local:21000/v2/relationship' > > > > > > * About to connect() to HW03.co.local port 21000 (#0) > > * Trying 172.18.4.48... > > * Connected to HW03.co.local (172.18.4.48) port 21000 (#0) > > * Server auth using Basic with user 'admin' > > > POST /v2/relationship HTTP/1.1 > > > Authorization: Basic xxxxxx > > > User-Agent: curl/7.29.0 > > > Host: HW03.co.local:21000 > > > Content-Type: application/json;charset=UTF-8 > > > Accept: application/json > > > Content-Length: 442 > > > > > * upload completely sent off: 442 out of 442 bytes > > < HTTP/1.1 404 Not Found > > < Date: Wed, 07 Aug 2019 01:07:44 GMT > > < Set-Cookie: ATLASSESSIONID=xxxxxx;Path=/;HttpOnly > > < X-Frame-Options: DENY > > < X-Content-Type-Options: nosniff > > < X-XSS-Protection: 1; mode=block > > < Strict-Transport-Security: max-age=31536000; includeSubDomains > > < Content-Type: text/html;charset=utf-8 > > < Content-Length: 2265 > > < Server: Jetty(9.3.14.v20161028) > > < > > <!doctype html> > > <!-- > > .... > > * > > * http://www.apache.org/licenses/LICENSE-2.0 > > .... > > --> > > <!--[if gt IE 8]> > > <script type="text/javascript"> > > function Redirect() { > > window.location.assign("login.jsp"); > > } > > Redirect(); > > </script> > > <![endif]--> > > <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media > queries --> > > <!--[if gt IE 7]> > > <script src="js/external_lib/es5-shim.min.js"></script> > > <script src="js/external_lib/respond.min.js"></script> > > <![endif]--> > > <html lang="en"> > > > > <head> > > <meta charset="utf-8"> > > <meta http-equiv="X-UA-Compatible" content="IE=edge"> > > <meta name="viewport" content="width=device-width, initial-scale=1"> > > <title>Atlas</title> > > .... > > </head> > > > > <body> > > <div id="wrapper"> > > <!-- Page Content Begin --> > > <div id="page-content-wrapper"> > > <div class="page-title clearfix"> > > <h3>Looking for something?</h3> > > <p>We're sorry. The web address you're looking for is not a > functioning page in Apache Atlas. Please try navigating from <a > href="index.html">Apache Atlas Home</a></p> > > </div> > > </div> > > <!-- Page Content End --> > > </div> > > </body> > > > > </html> > > * Connection #0 to host HW03.co.local left intact > > does not work and not sure what to do about the error message. > > What could be going wrong here? Are there any better docs than those > linked to for understanding the API? > > > This electronic message is intended only for the named > recipient, and may contain information that is confidential or > privileged. If you are not the intended recipient, you are > hereby notified that any disclosure, copying, distribution or > use of the contents of this message is strictly prohibited. If > you have received this message in error or are not the named > recipient, please notify us immediately by contacting the > sender at the electronic mail address noted above, and delete > and destroy all copies of this message. Thank you. > > -- This electronic message is intended only for the named recipient, and may contain information that is confidential or privileged. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the contents of this message is strictly prohibited. If you have received this message in error or are not the named recipient, please notify us immediately by contacting the sender at the electronic mail address noted above, and delete and destroy all copies of this message. Thank you.
