Support Questions

Find answers, ask questions, and share your expertise

couldn't create kafka policy from Ranger REST API

New Contributor

Hello everyone,

When try to create a kafka policy from Ranger REST API show the following error:

curl -i --header "Accept:application/json" -H "Content-Type: application/json" -u admin:admin -X POST http://nodo1.dominio.es:6080/service/public/api/policy -d '{ "policyName":"kafka-testing-policy","topic":"lending","description":"Testing","repositoryName":"PoC_Cognosfera_kafka","repositoryType":"kafka","permMapList":[{"userList":["test"],"permList":["publish"]}]}' HTTP/1.1 204 No Content Server: Apache-Coyote/1.1 Set-Cookie: RANGERADMINSESSIONID=4505EDD011A2D4969CDFF618D9EB9280; Path=/; HttpOnly WWW-Authenticate: Negotiate Set-Cookie: hadoop.auth=; Path=/; Domain=hadoopmaster2.kst.internal; Expires=Thu, 01-Jan-1970 00:00:00 GMT; HttpOnly X-Frame-Options: DENY Content-Type: application/json Date: Fri, 26 May 2017 11:16:56 GMT

Is it possible create a kafka policy from REST API? because i don't find any documentation about that.

Many thanks,

César

2 REPLIES 2

Cloudera Employee

@Cesar Gonzales Ranger supports next version (v2) of REST APIs in ranger-0.5 and later versions. Please refer to this doc for ranger-0.6 release.

Abhay

New Contributor

Many thanks @akulkarni It worked!!

curl -i --header "Accept:application/json" -H "Content-Type: application/json" -u admin:admin -X POST http://nodo1.dominio.es:6080/service/public/v2/api/policy -d '{"name":"lending_2","service":"PoC_Cognosfera_kafka","isEnabled":"true","isAuditEnabled":"true","policyType":"0","policyItems":[{"users":["test"],"accesses":[{"isAllowed":"true","type":"publish"}]}],"resources":{"topic":{"values":["prueba"]}}}'

HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Set-Cookie: RANGERADMINSESSIONID=8DA224285F1E8FE1E5EF3E7ABA956284; Path=/; HttpOnly WWW-Authenticate: Negotiate Set-Cookie: hadoop.auth=; Path=/; Domain=hadoopmaster2.kst.internal; Expires=Thu, 01-Jan-1970 00:00:00 GMT; HttpOnly X-Frame-Options: DENY Content-Type: application/json Transfer-Encoding: chunked Date: Mon, 29 May 2017 09:02:35 GMT