Support Questions

Find answers, ask questions, and share your expertise

rest api to provide views in ambari

avatar

I am executing this curl command ,When I provide files view to a particular user, then in files views, only that user persisted and other users get deleted.

admin-> manage amabri -> views > files : here I find only user whom i given access with this curl command but users those were earlier there got deleted

curl -i -u $Ambariadmin:$ambaripass -H "X-Requested-By: ambari" -X PUT -d '[{"PrivilegeInfo":{"permission_name":"VIEW.USER","principal_name":"'$username'","principal_type":"USER"}}]' http://localhost:8080/api/v1/views/$viewname/versions/$version/instances/$instance/privileges

1 ACCEPTED SOLUTION

avatar
Master Mentor

@Anurag Mishra

- You will need to pass all the previous user privilege details as well along with the new user when you want to edit the list using API call:

Example if you already have users privilleges for "123jay", "jay". Now you want to add another user "jayyarn" in the privilleges list then you should PUT the whole list again.

Example:

curl -i -u $Ambariadmin:$ambaripass -H "X-Requested-By: ambari" -X PUT  -d '[{"PrivilegeInfo":{"permission_name":"VIEW.USER","principal_name":"123jay","principal_type":"USER"}},{"PrivilegeInfo":{"permission_name":"VIEW.USER","principal_name":"jay","principal_type":"USER"}},{"PrivilegeInfo":{"permission_name":"VIEW.USER","principal_name":"jayyarn","principal_type":"USER"}},{"PrivilegeInfo":{"permission_name":"VIEW.USER","principal_name":"CLUSTER.ADMINISTRATOR","principal_type":"ROLE"}},{"PrivilegeInfo":{"permission_name":"VIEW.USER","principal_name":"CLUSTER.OPERATOR","principal_type":"ROLE"}},{"PrivilegeInfo":{"permission_name":"VIEW.USER","principal_name":"SERVICE.OPERATOR","principal_type":"ROLE"}},{"PrivilegeInfo":{"permission_name":"VIEW.USER","principal_name":"SERVICE.ADMINISTRATOR","principal_type":"ROLE"}},{"PrivilegeInfo":{"permission_name":"VIEW.USER","principal_name":"CLUSTER.USER","principal_type":"ROLE"}}]'   http://localhost:8080/api/v1/views/$viewname/versions/$version/instances/$instance/privileges

.

View solution in original post

2 REPLIES 2

avatar

@Jay SenSharma could you pls look into issue

avatar
Master Mentor

@Anurag Mishra

- You will need to pass all the previous user privilege details as well along with the new user when you want to edit the list using API call:

Example if you already have users privilleges for "123jay", "jay". Now you want to add another user "jayyarn" in the privilleges list then you should PUT the whole list again.

Example:

curl -i -u $Ambariadmin:$ambaripass -H "X-Requested-By: ambari" -X PUT  -d '[{"PrivilegeInfo":{"permission_name":"VIEW.USER","principal_name":"123jay","principal_type":"USER"}},{"PrivilegeInfo":{"permission_name":"VIEW.USER","principal_name":"jay","principal_type":"USER"}},{"PrivilegeInfo":{"permission_name":"VIEW.USER","principal_name":"jayyarn","principal_type":"USER"}},{"PrivilegeInfo":{"permission_name":"VIEW.USER","principal_name":"CLUSTER.ADMINISTRATOR","principal_type":"ROLE"}},{"PrivilegeInfo":{"permission_name":"VIEW.USER","principal_name":"CLUSTER.OPERATOR","principal_type":"ROLE"}},{"PrivilegeInfo":{"permission_name":"VIEW.USER","principal_name":"SERVICE.OPERATOR","principal_type":"ROLE"}},{"PrivilegeInfo":{"permission_name":"VIEW.USER","principal_name":"SERVICE.ADMINISTRATOR","principal_type":"ROLE"}},{"PrivilegeInfo":{"permission_name":"VIEW.USER","principal_name":"CLUSTER.USER","principal_type":"ROLE"}}]'   http://localhost:8080/api/v1/views/$viewname/versions/$version/instances/$instance/privileges

.