Created on 12-07-2018 06:37 PM - edited 08-17-2019 04:12 PM
Hello,
I would like to know if is possible to add a Permission Group to the HIVE View (Hive View 2.0) using REST API....
The Group has been created and defined.
Thanks in advance,
Daniel
Created 12-10-2018 04:40 AM
Hi @Daniel Issaharoff ,
Can you please try the following REST API :
curl -u <USERNAME>:<PASSWORD> -H "X-Requested-By:ambari" -i -X POST http://<AMBARIFQDN>:8080/api/v1/views/HIVE/versions/2.0.0/instances/<HIVE_INSTANCE_NAME>/privileges -d '[{ "PrivilegeInfo": { "permission_name": "VIEW.USER", "principal_name": "<YOUR DESIRED GROUP NAME>", "principal_type": "GROUP" } }]'
for ex :
here qa is the new group privilage i am adding for my AUTO_HIVE20_INSTANCE
curl -u admin:admin -H "X-Requested-By:ambari" -i -X POST http://asnaik1.openstacklocal:8080/api/v1/views/HIVE/versions/2.0.0/instances/AUTO_HIVE20_INSTANCE/p... -d '[{ "PrivilegeInfo": { "permission_name": "VIEW.USER", "principal_name": "qa", "principal_type": "GROUP" } }]'
If this is the answer you are looking for please accept my answer.
Created 12-10-2018 04:40 AM
Hi @Daniel Issaharoff ,
Can you please try the following REST API :
curl -u <USERNAME>:<PASSWORD> -H "X-Requested-By:ambari" -i -X POST http://<AMBARIFQDN>:8080/api/v1/views/HIVE/versions/2.0.0/instances/<HIVE_INSTANCE_NAME>/privileges -d '[{ "PrivilegeInfo": { "permission_name": "VIEW.USER", "principal_name": "<YOUR DESIRED GROUP NAME>", "principal_type": "GROUP" } }]'
for ex :
here qa is the new group privilage i am adding for my AUTO_HIVE20_INSTANCE
curl -u admin:admin -H "X-Requested-By:ambari" -i -X POST http://asnaik1.openstacklocal:8080/api/v1/views/HIVE/versions/2.0.0/instances/AUTO_HIVE20_INSTANCE/p... -d '[{ "PrivilegeInfo": { "permission_name": "VIEW.USER", "principal_name": "qa", "principal_type": "GROUP" } }]'
If this is the answer you are looking for please accept my answer.
Created 12-10-2018 03:35 PM
Hello @Akhil S Naik
Thanks a lot for your prompt reply.... and of course, for your help! It worked!
(I needed to convert it to a PowerShell Invoke-WebRequest call, but it worked fine!
I'm working in an Azure HDInsight cluster, and when the cluster starts Ambari does not have the group defined in the Hive view.
(I don't know why Ambari does not keep that information...)
Once again, Thanks for your help.
Regards,
Daniel
Created 12-10-2018 03:40 PM
For those interested in using this in PowerShell, This is the way I'm calling the REST-API:
$Headers = @{'X-Requested-By' = 'ambari'} $Body = '[{"PrivilegeInfo": { "permission_name": "VIEW.USER", "principal_name": "group_poc", "principal_type": "GROUP" } }]' $Resp = Invoke-WebRequest -Method Post -Uri "https://<Your-Cluster-Name>/api/v1/views/HIVE/versions/2.0.0/instances/AUTO_HIVE20_INSTANCE/privileges/" -Credential <Your-Credentials> -Headers $Headers -Body $Body