You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by ma...@apache.org on 2020/12/14 18:44:04 UTC

[ranger] 01/03: RANGER-2927: updated README.md for Python client

This is an automated email from the ASF dual-hosted git repository.

madhan pushed a commit to branch ranger-2.1
in repository https://gitbox.apache.org/repos/asf/ranger.git

commit f9f42211562891e583309047de003823590f9b14
Author: Madhan Neethiraj <ma...@apache.org>
AuthorDate: Fri Dec 4 00:19:31 2020 -0800

    RANGER-2927: updated README.md for Python client
    
    (cherry picked from commit 789ce7dacb7c0d7899549dbd8082430f1d4bd4d8)
---
 intg/src/main/python/README.md | 47 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)

diff --git a/intg/src/main/python/README.md b/intg/src/main/python/README.md
index 8cd7b03..305e7f5 100644
--- a/intg/src/main/python/README.md
+++ b/intg/src/main/python/README.md
@@ -19,3 +19,50 @@ under the License.
 
 # 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](https://pip.pypa.io/en/stable/) to install python client for Apache Ranger.
+
+```bash
+> pip install apache-ranger
+```
+
+Verify if apache-ranger client is installed:
+```bash
+> pip list
+
+Package      Version
+------------ ---------
+apache-ranger 0.0.1
+```
+
+## Usage
+
+```python init_dev_hive.py```
+```python
+# 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](https://github.com/apache/ranger/blob/master/ranger-examples/sample-client/src/main/python/sample_client.py) module.