Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Ambari - Manage HIVE view - Add Groups using REST

avatar
New Contributor

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

93796-hiveviewpermissions.png

1 ACCEPTED SOLUTION

avatar

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.

View solution in original post

3 REPLIES 3

avatar

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.

avatar
New Contributor

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

avatar
New Contributor

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