Skip to main content

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


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)

Uploaded Source

Built Distribution

apache_ranger-0.0.2-py3-none-any.whl (20.7 kB view hashes)

Uploaded Python 3

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