Requirement:
I have many HDI Clusters (Spark, LLAP) and i want to create a ranger policy automatically whenever any new database created.
Solution:
To achieve this requirement i have used the rest API.A RESTful API is an application program interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data.
Reference information for the Ranger REST API
service/public/v2/api/policy.
I have many HDI Clusters (Spark, LLAP) and i want to create a ranger policy automatically whenever any new database created.
Solution:
To achieve this requirement i have used the rest API.A RESTful API is an application program interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data.
API Name
|
Create Policy
|
Request Type
|
POST
|
Request URL
|
service/public/v2/api/policy
|
Request Params
|
{
"policyName":"<<PolicyName>>",
"resourceName":"/*/*",
"description":"",
"repositoryName":"HiveRepositoryName",
"repositoryType":"hive",
"permMapList":[{"userList":[],"groupList":["groupname"],"permList":["select","Read"]}],
"tables":"*",
"columns":"*",
"databases":"<<PolicyName>>",
"tableType":"Inclusion",
"columnType":"Inclusion",
"isEnabled":true,
"isRecursive":false,
"isAuditEnabled":true,
"version":"1",
"replacePerm":false
}
|
Sample Code:
I have created a shell script to call the CURL command. Here
is the sample code,
API Name
|
Create Policy
|
Request Type
|
POST
|
Request URL
|
Labhdi-int.azurehdinsight.net/ranger/service/public/api/policy/
|
CURL Command
|
curl -iv -u username:password
-H "Content-Type:
application/json"
-d
'{
"policyName":"<<PolicyName>>",
"resourceName":"/*/*",
"description":"",
"repositoryName":"HiveRepositoryName",
"repositoryType":"hive",
"permMapList":[{"userList":[],"groupList":["g_az_devadls_data_raw_1crussia_readonly"],"permList":["select","Read"]}],
"tables":"*",
"columns":"*",
"databases":"<<PolicyName>>",
"tableType":"Inclusion",
"columnType":"Inclusion",
"isEnabled":true,
"isRecursive":false,
"isAuditEnabled":true,
"version":"1",
"replacePerm":false
}'
-X POST
https://labhdi-int.azurehdinsight.net/ranger/service/public/api/policy/
|
No comments:
Post a Comment