Community Articles

Find and share helpful community-sourced technical articles.
Labels (1)
avatar

1. Create User

[root@chupa1 ~]# curl -iv -u admin:admin -H "X-Requested-By: ambari" -X POST -d '{"Users/user_name":"dav","Users/password":"pass","Users/active":"true","Users/admin":"false"}' http://localhost:8080/api/v1/users 
* About to connect() to localhost port 8080 (#0) 
* Trying ::1... connected 
* Connected to localhost (::1) port 8080 (#0) 
* Server auth using Basic with user 'admin' 
> POST /api/v1/users HTTP/1.1 
> Authorization: Basic YWRtaW46YWRtaW4= 
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.16.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2 
> Host: localhost:8080 
> Accept: */* 
> X-Requested-By: ambari 
> Content-Length: 93 
> Content-Type: application/x-www-form-urlencoded 
> 
< HTTP/1.1 201 Created 
HTTP/1.1 201 Created 

2. Create Group

[root@chupa1 ~]# curl -iv -u admin:admin -H "X-Requested-By: ambari" -X POST -d '{"Groups/group_name":"davgroup"}' http://localhost:8080/api/v1/groups 
* About to connect() to localhost port 8080 (#0) 
* Trying ::1... connected 
* Connected to localhost (::1) port 8080 (#0) 
* Server auth using Basic with user 'admin' 
> POST /api/v1/groups HTTP/1.1 
> Authorization: Basic YWRtaW46YWRtaW4= 
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.16.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2 
> Host: localhost:8080 
> Accept: */* 
> X-Requested-By: ambari 
> Content-Length: 32 
> Content-Type: application/x-www-form-urlencoded 
> 
< HTTP/1.1 201 Created 
HTTP/1.1 201 Created 

3. Map user to Group

[root@chupa1 ~]# curl -iv -u admin:admin -H "X-Requested-By: ambari" -X POST -d '{"MemberInfo/user_name":"dav", "MemberInfo/group_name":"davgroup"}' http://localhost:8080/api/v1/groups/davgroup/members 
* About to connect() to localhost port 8080 (#0) 
* Trying ::1... connected 
* Connected to localhost (::1) port 8080 (#0) 
* Server auth using Basic with user 'admin' 
> POST /api/v1/groups/davgroup/members HTTP/1.1 
> Authorization: Basic YWRtaW46YWRtaW4= 
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.16.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2 
> Host: localhost:8080 
> Accept: */* 
> X-Requested-By: ambari 
> Content-Length: 66 
> Content-Type: application/x-www-form-urlencoded 
> 
< HTTP/1.1 201 Created 
HTTP/1.1 201 Created
3,442 Views
Comments

can you guide me how to create a read-only user by ambari rest api

How to assign privileges to a group when it is created?