Apache Ranger Python client
Project description
Apache Ranger - Python client
This is a python library for Apache Ranger. Users can integrate with Apache Ranger using the python client. Currently, compatible with Python 3.5+
Installation
Use the package manager pip to install python client for Apache Ranger.
> pip install apache-ranger
Verify if apache-ranger client is installed:
> pip list
Package Version
------------ ---------
apache-ranger 0.0.2
Usage
python init_dev_hive.py
# init_dev_hive.py
from apache_ranger.model.ranger_service import RangerService
from apache_ranger.client.ranger_client import RangerClient
from apache_ranger.model.ranger_policy import RangerPolicy, RangerPolicyResource, RangerPolicyItem, RangerPolicyItemAccess
service_name = 'dev_hive'
service = RangerService(name=service_name, type='hive')
service.configs = {'username':'hive', 'password':'hive', 'jdbc.driverClassName': 'org.apache.hive.jdbc.HiveDriver', 'jdbc.url': 'jdfb:hive2://ranger-hadoop:10000', 'hadoop.security.authorization': 'true'}
policy = RangerPolicy(service=service_name, name='test policy')
policy.resources = {'database': RangerPolicyResource(['test_db']), 'table': RangerPolicyResource(['test_tbl']), 'column': RangerPolicyResource(['*'])}
policy.policyItems.append(RangerPolicyItem(users=['admin'], accesses=[RangerPolicyItemAccess('create'), RangerPolicyItemAccess('alter'), RangerPolicyItemAccess('drop')], delegateAdmin=True))
policy.denyPolicyItems.append(RangerPolicyItem(users=['admin'], accesses=[RangerPolicyItemAccess('select')]))
ranger_client = RangerClient('http://localhost:6080', 'admin', 'rangerR0cks!')
created_service = ranger_client.create_service(service)
created_policy = ranger_client.create_policy(policy)
For more examples, checkout sample-client
python project in ranger-examples module.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
apache-ranger-0.0.2.tar.gz
(9.5 kB
view hashes)
Built Distribution
Close
Hashes for apache_ranger-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b374d97e09014d41a70b8a389d8a208f1210562c396301b60cabacb82e88c3c |
|
MD5 | 4a0a1370497413080855d514d3ef7048 |
|
BLAKE2b-256 | 6a19b5ff82e178588b5abac162493d1953c277692fa11f1fe1f03e0a1377c335 |