Skip to content

Commit

Permalink
doc for Typedefs and Search
Browse files Browse the repository at this point in the history
  • Loading branch information
jpoullet2000 committed Feb 28, 2018
1 parent a7a1684 commit e51c9ad
Show file tree
Hide file tree
Showing 5 changed files with 1,984 additions and 44 deletions.
1 change: 1 addition & 0 deletions atlasclient/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = '0.1.0'
11 changes: 8 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

import sys
import os
here = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, os.path.abspath('..'))
from atlasclient import __version__ as version

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -43,17 +46,19 @@
master_doc = 'index'

# General information about the project.
project = u'Atlas client in Python'
project = u'Apache Atlas client in Python'
copyright = u'2018, JB Poullet'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = '1.0'
#version = setup_args['version']
version = version
# The full version, including alpha/beta/rc tags.
release = '1.0'
#release = setup_args['version']
release = version

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
170 changes: 133 additions & 37 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,33 +22,73 @@ The following groups of resources can be accessed:
Below a few examples to access some of the resources.

Make sure atlasclient is properly installed (see `here <installation.html>`__).

First you need to create a connection object::

from atlasclient.client import Atlas
client = Atlas(your_atlas_host, port=21000, username='admin', password='admin')
from atlasclient.client import Atlas
client = Atlas(your_atlas_host, port=21000, username='admin', password='admin')

Replace `your_atlas_host` by the actual host name of the Atlas server. Note that port 21000 might also be different in your case. Port 21000 is default port when using HTTP with Atlas, and 21443 for HTTPS.

To access the list of entry points::

from atlasclient.client import ENTRY_POINTS
ENTRY_POINTS

You'll get a dictionary with ('key': 'value') corresponding to ('client method': 'model class'): `{'entity_guid': <class 'atlasclient.models.EntityGuid'>, ...}`.
For example, we can use::

client.entity_guid(GUID)

'entity_guid' is used as a method of the 'client' object.


DiscoveryREST
-------------

This section explains how you can search for entities per attribute name, or search using a SQL-like query, and more ;).


Search by attribute
~~~~~~~~~~~~~~~~~~~

To search for entities with a special attribute name::

params = {'attrName': 'name', 'attrValue': 'data', 'offset': '1', 'limit':'10'}
search_results = client.search_attribute(**params)
# Info about all entities in one dict
for s in search_results:
print(s._data)
# Getting name and guid of each entity
for s in search_results:
for e in s.entities:
print(e.name)
print(e.guid)
params = {'attrName': 'name', 'attrValue': 'data', 'offset': '1', 'limit': '10'}
search_results = client.search_attribute(**params)
# Info about all entities in one dict
for s in search_results:
print(s._data)
# Getting name and guid of each entity
for s in search_results:
for e in s.entities:
print(e.name)
print(e.guid)


Search with basic terms
~~~~~~~~~~~~~~~~~~~~~~~

To retrieve data for the specified full text query::

params = {'attrName': 'name', 'attrValue': 'data', 'offset': '1', 'limit': '10'}
search_results = client.search_basic(**params)
for s in search_results:
for e in s.entities
print(e.guid)

Search by DSL
~~~~~~~~~~~~~

To retrieve data for the specified DSL::

TO BE CONTINUED...
params = {'typeName': 'hdfs_path', 'classification': 'Confidential'}
search_results = client.search_dsl(**params)
for s in search_results:
for e in s.entities:
print(e.classificationNames)
print(e.attributes)


EntityREST
Expand Down Expand Up @@ -254,7 +294,10 @@ Get lineage by GUID

To get lineage info about entity identified by GUID::

client.lineage_guid(GUID)
lineage = client.lineage_guid(GUID)
print(lineage.relations)
print(lineage.lineageDirection)


RelationshipREST
----------------
Expand Down Expand Up @@ -285,6 +328,8 @@ We can access the classification types in a similar way::
for classification_type in t.classificationDefs:
print(classification_type.description)

Idem for entityDefs and structDefs.


Delete typeDefs
~~~~~~~~~~~~~~~
Expand All @@ -307,70 +352,121 @@ TO BE DONE...
Get typeDefs headers
~~~~~~~~~~~~~~~~~~~~

TO BE DONE...
To get typedefs headers::

for header in client.typedefs_headers:
print(header.name)
print(header.category)


Get classificationDefs by GUID
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

TO BE DONE...
To get classificationdefs by GUID::

class_defs = client.classificationdef_guid(CLASSIFICATION_GUID)
class_defs.name
class_defs._data


Get classificationDefs by name
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

TO BE DONE...
To get classificationdefs by name::
CLASSIFICATION_NAME = 'Confidential'
class_defs = client.classificationdef_name(CLASSIFICATION_NAME)
class_defs.description


Get entityDefs by GUID
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~

TO BE DONE...
To get entitydefs by GUID::
entity_defs = client.entitydef_guid(ENTITY_GUID)
entity_defs.description

Get entityDefs by name
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~

TO BE DONE...
To get entitydefs by name::

ENTITY_NAME = 'hdfs_path'
entity_defs = client.entitydef_name(ENTITY_NAME)
entity_defs.description


Get enumDefs by GUID
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~


To get enumdefs by GUID::

enum_defs = client.enumdef_guid(ENUM_GUID)
enum_defs.elementDefs

TO BE DONE...

Get enumDefs by name
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~

TO BE DONE...
To get enumdefs by name::

ENUM_NAME = 'file_action'
enum_defs = client.enumdef_name(ENUM_NAME)
enum_defs.elementDefs


Get relationshipDefs by GUID
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To get relationshipdefs by GUID::

relationship_defs = client.relationshipdef_guid(RELATIONSHIP_GUID)
relationship_defs._data

TO BE DONE...

Get relationshipDefs by name
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

TO BE DONE...
To get relationshipdefs by name::

relationship_defs = client.relationshipdef_guid(RELATIONSHIP_NAME)
relationship_defs._data


Get structDefs by GUID
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~

TO BE DONE...
To get structdefs by GUID::

struct_defs = client.structdef_guid(STRUCT_GUID)
struct_defs._data

Get structDefs by name
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~

TO BE DONE...
To get structdefs by name::

struct_defs = client.structdef_guid(STRUCT_NAME)
struct_defs._data


Get typeDefs by GUID
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~

To get typedefs by GUID::

type_defs = client.typedef_guid(TYPE_GUID)
type_defs._data

TO BE DONE...

Get typeDefs by name
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~

To get typedefs by name::

type_defs = client.typedef_guid(TYPE_NAME)
type_defs._data

TO BE DONE...
17 changes: 13 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@

from setuptools import setup, find_packages
import os
import sys

with open('README.rst') as readme_file:
here = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, here)
from atlasclient import __version__ as version


with open(os.path.join(here, 'README.rst')) as readme_file:
readme = readme_file.read()

with open('HISTORY.rst') as history_file:
with open(os.path.join(here, 'HISTORY.rst')) as history_file:
history = history_file.read()

requirements_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'requirements.txt')
Expand All @@ -25,9 +31,10 @@
with open(setup_requirements_path) as setup_requirements_file:
setup_requirements = setup_requirements_file.readlines()

setup(
setup_args = {}
setup_args = dict(
name='atlasclient',
version='0.1.0',
version=version,
description="Apache Atlas client",
long_description=readme + '\n\n' + history,
author="Jean-Baptiste Poullet",
Expand All @@ -54,3 +61,5 @@
tests_require=test_requirements,
#setup_requires=setup_requirements,
)

setup(**setup_args)
Loading

0 comments on commit e51c9ad

Please sign in to comment.