Madhan, this is very good. Does the script also supports deleting or modifying of Ranger Policies?
Regards Bosco On 12/4/20, 9:09 AM, "Madhan Neethiraj" <mad...@apache.org> wrote: All, Official Python client for Apache Ranger is now available at https://pypi.org/project/apache-ranger/. Python client APIs mirror Apache Ranger REST APIs, and enable administration of Apache Ranger using Python. Here is a sample usage to create a service and a policy using Python client: 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) Apache Ranger team is updating the documentation to include details of Python APIs. Your feedback and suggestions are welcome. Thanks, Madhan