Skip to main content

This atlas python api can generate atlas entities and import them into an Atlas server instances.

Project description

Apache Atlas Client in Python

This python client is only compatible with Apache Atlas REST API v2.

In this repository, we develop a python api to generate atlas entities and import them into atlas instances.

Quick start

Create a client to connect to an Atlas instance

from atlas_client.client import Atlas
# login with your token
hostname = "https://atlas.lab.sspcloud.fr"
port = 443
oidc_token = "<your_token>"
atlas_client = Atlas(hostname, port, oidc_token=oidc_token)

# login with your username and password
atlas_client = Atlas(hostname, port, username='',password='')

Search entity and return entity's guid

from atlas_client.entity_search.EntityFinder import EntityFinder

finder = EntityFinder(atlas_client)
search_result = finder.search_full_text("aws_s3_bucket", "test")

EntityFinder.show_search_results(search_result)
entity_number = EntityFinder.get_entity_number(search_result)
print("Find " + str(entity_number) + " result in total")

guid_list = EntityFinder.get_result_entity_guid_list(search_result)

for guid in guid_list:
    print("result:" + guid)

Atlas entities CRUD

S3 entities

from atlas_client.entity_management.s3.S3BucketManager import S3BucketManager

s3_bucket_manager = S3BucketManager(atlas_client)

# creat s3 bucket in atlas
name = "test"
domain = "s3://test.org"
qualified_name = "s3://test.org/test1"
description = "test for me"
s3_bucket_manager.create_entity(name, domain, qualified_name, description)
# get s3 bucket via guid
guid = "9642d134-4d0e-467c-8b36-ca73902d4c14"
e = s3_bucket_manager.get_entity(guid)
s3_bucket_manager.show_entity_attributes(e)
e_attributes = s3_bucket_manager.get_entity_attributes(e)
e_attributes_key_list = s3_bucket_manager.get_s3_attributes_key_list(e)
print(e_attributes_key_list)
print(e_attributes['description'])

# update s3 bucket attributes
s3_bucket_manager.update_entity(guid, 'description', 'update description from api')

# delete s3 bucket
s3_bucket_manager.delete_entity(guid)

Hive entities

hive_db = HiveDBManager(atlas_client)
hive_table = HiveTableManager(atlas_client)
hive_column = HiveColumnManager(atlas_client)

# insert hive tables
hive_db.create_entity("pengfei-stock", "pengfei.org", "database for my stock market",owner="pliu",location="pengfei.org")
hive_table.create_entity("favorite", "pengfei.org@pengfei-stock", "favorite stock")
hive_column.create_entity("stock_id", "int", "pengfei.org@pengfei-stock.favorite", "id of the stock")
hive_column.create_entity("stock_name", "string", "pengfei.org@pengfei-stock.favorite", "name of the stock")

Generate atlas entity json file

If you want to use the Atlas rest api by yourself, we also provide you the support of json file generation

from atlas_client.entity_source_generation.S3BucketEntityGenerator import S3BucketEntityGenerator
name = "test"
domain = "s3://test.org"
qualified_name = "s3://test.org/test1"
description = "test for me"

s3_bucket_json_source = S3BucketEntityGenerator.generate_s3_bucket_json_source(name, domain,qualified_name,description
                                                                               , creator_id="toto")
print(s3_bucket_json_source)

Package organization

entity_source_generation

In the entity_source_generation folder, you can find various templates and generators for generating atlas entities.

entity_search

In the entity_search folder, you can find EntityFinder which help you to find entity in an Atlas instance

entity_management

In the entity_management folder, you can find various rest client to upload entities into atlas

docs

In the docs folder, you can find helper function which shows which entity type and attributes are supported by this api

Prerequisites

This tool only requires python 3.7 or above

Supported OS

Windows XP/7/8/10

Linux

MacOS

Authors

  • Pengfei Liu

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgement

This package was created by using verdan/pyatlasclient project

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

atlaspyapi-0.2.1.tar.gz (31.9 kB view details)

Uploaded Source

Built Distribution

atlaspyapi-0.2.1-py3-none-any.whl (50.9 kB view details)

Uploaded Python 3

File details

Details for the file atlaspyapi-0.2.1.tar.gz.

File metadata

  • Download URL: atlaspyapi-0.2.1.tar.gz
  • Upload date:
  • Size: 31.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12

File hashes

Hashes for atlaspyapi-0.2.1.tar.gz
Algorithm Hash digest
SHA256 1830f1739e2b5fc8d70b656ec98cfce7c421e8b6abbefb41bc02375de6dece06
MD5 34fdc1a81b4a7b58b14fb43567990dc1
BLAKE2b-256 c78af313b76500fb0e1a16728550726455b6d42bfef24187256ab6ca20eca487

See more details on using hashes here.

File details

Details for the file atlaspyapi-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: atlaspyapi-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 50.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12

File hashes

Hashes for atlaspyapi-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 389c92869127bb18cdcb35a5664f173d51049478861748d3ce9ef36a48854876
MD5 2e9243b26beafd4bd834ea8a09db5015
BLAKE2b-256 d6ac3a645ba1b2ab8d60015e7376c274e932083f6c8c20c6299d03c0df88b406

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page