<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Adding new Ambari user with assigned group with API in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Adding-new-Ambari-user-with-assigned-group-with-API/m-p/166791#M37058</link>
    <description>&lt;P&gt;My assumption was this was a new group. Yes, POST would work for existing groups. &lt;/P&gt;</description>
    <pubDate>Fri, 05 Aug 2016 19:55:21 GMT</pubDate>
    <dc:creator>sbhat</dc:creator>
    <dc:date>2016-08-05T19:55:21Z</dc:date>
    <item>
      <title>Adding new Ambari user with assigned group with API</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Adding-new-Ambari-user-with-assigned-group-with-API/m-p/166784#M37051</link>
      <description>&lt;P&gt;I would like to add a new user to Ambari Views and add it to a group.&lt;/P&gt;&lt;P&gt;Here is my file:&lt;/P&gt;&lt;PRE&gt;{
    "Users/user_name": "user1",
    "Users/password":  "user1",
    "Users/groups": ["group1"],
    "Users/active": true,
    "Users/admin": false
}
&lt;/PRE&gt;&lt;P&gt;So I run the file:&lt;/P&gt;&lt;PRE&gt;curl -iv -u admin:admin -d @user1.amb -H "X-Requested-By: ambari" -X POST &lt;A href="http://ambari-server:8080/api/v1/users" target="_blank"&gt;http://ambari-server:8080/api/v1/users&lt;/A&gt;&lt;/PRE&gt;&lt;P&gt;The user is created, but not added to the group. Here is the GET output for this user:&lt;/P&gt;&lt;PRE&gt;{
  "href" : "http://ambari-server:8080/api/v1/users/user1",
  "Users" : {
    "active" : true,
    "admin" : false,
    "groups" : [ ],
    "ldap_user" : false,
    "user_name" : "user1"
  },
  "widget_layouts" : [ ],
  "privileges" : [ ]
}&lt;/PRE&gt;&lt;P&gt;Groups is empty. Does anyone have any idea what Im doing wrong in this user creation process?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2016 16:41:57 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Adding-new-Ambari-user-with-assigned-group-with-API/m-p/166784#M37051</guid>
      <dc:creator>marko_kole</dc:creator>
      <dc:date>2016-08-05T16:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: Adding new Ambari user with assigned group with API</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Adding-new-Ambari-user-with-assigned-group-with-API/m-p/166785#M37052</link>
      <description>&lt;P&gt;Hi &lt;A rel="user" href="https://community.cloudera.com/users/931/marko-kole.html" nodeid="931"&gt;@marko&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;You may add the user to a group using the following steps :&lt;/P&gt;&lt;P&gt;1) add a user using API :&lt;/P&gt;&lt;PRE&gt;curl -iv -u admin:admin -H "X-Requested-By: ambari" -X POST -d '{"Users/user_name":"{USER}","Users/password":"{PASSWORD}","Users/active":"{ISACTIVE}","Users/admin":"{ISADMIN}"}' &lt;A href="http://ambari-server:8080/api/v1/users" target="_blank"&gt;http://ambari-server:8080/api/v1/users&lt;/A&gt;&lt;/PRE&gt;&lt;P&gt;2) add a group using API :&lt;/P&gt;&lt;PRE&gt;curl -iv -u admin:admin -H "X-Requested-By: ambari" -X POST -d '{"Groups/group_name":"{GROUP_NAME}"}' &lt;A href="http://ambari-server:8080/api/v1/groups" target="_blank"&gt;http://ambari-server:8080/api/v1/groups&lt;/A&gt;&lt;/PRE&gt;&lt;P&gt;3) add the user to the group :&lt;/P&gt;&lt;PRE&gt;curl -iv -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '[{"MemberInfo/user_name":"{USER_NAME}","MemberInfo/group_name":"{GROUP_NAME}"}]' &lt;A href="http://ambari-server:8080/api/v1/groups/{GROUP_NAME}/members" target="_blank"&gt;http://ambari-server:8080/api/v1/groups/{GROUP_NAME}/members&lt;/A&gt;&lt;/PRE&gt;&lt;P&gt;Change {USER_NAME} to the user name you want and {GROUP_NAME} to the group you want&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2016 16:53:28 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Adding-new-Ambari-user-with-assigned-group-with-API/m-p/166785#M37052</guid>
      <dc:creator>sbhat</dc:creator>
      <dc:date>2016-08-05T16:53:28Z</dc:date>
    </item>
    <item>
      <title>Re: Adding new Ambari user with assigned group with API</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Adding-new-Ambari-user-with-assigned-group-with-API/m-p/166786#M37053</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/1902/sbhat.html" nodeid="1902"&gt;@sbhat&lt;/A&gt; &lt;/P&gt;&lt;P&gt;I ran what you recommended  under adding user to a group and Im getting 405 Method not allowed.&lt;/P&gt;&lt;P&gt;I tried with -X POST rather than PUT and Im getting this error:&lt;/P&gt;&lt;PRE&gt;{
  "status" : 400,
  "message" : "The properties [MemberInfo/user_name, MemberInfo/group_name] specified in the request or predicate are not supported for the resource type Group."
* Connection #0 to host ambari-server left intact
}&lt;/PRE&gt;&lt;P&gt;so I updated the string by adding members/ in front of MemberInfo, like this:&lt;/P&gt;&lt;PRE&gt;{
  "members/MemberInfo/user_name":"user1",
  "members/MemberInfo/group_name":"group1"
}
&lt;/PRE&gt;&lt;P&gt;and the error is the same.&lt;/P&gt;&lt;P&gt;Im using Ambari 2.2.2.0 if this has to do with anything.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2016 18:28:53 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Adding-new-Ambari-user-with-assigned-group-with-API/m-p/166786#M37053</guid>
      <dc:creator>marko_kole</dc:creator>
      <dc:date>2016-08-05T18:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: Adding new Ambari user with assigned group with API</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Adding-new-Ambari-user-with-assigned-group-with-API/m-p/166787#M37054</link>
      <description>&lt;P&gt;Sorry about that. I have updated the answer with the right URI to add user to groups : &lt;A href="http://ambari-server:8080/api/v1/groups/{GROUP_NAME}/members" target="_blank"&gt;http://ambari-server:8080/api/v1/groups/{GROUP_NAME}/members&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2016 18:34:44 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Adding-new-Ambari-user-with-assigned-group-with-API/m-p/166787#M37054</guid>
      <dc:creator>sbhat</dc:creator>
      <dc:date>2016-08-05T18:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Adding new Ambari user with assigned group with API</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Adding-new-Ambari-user-with-assigned-group-with-API/m-p/166788#M37055</link>
      <description>&lt;P&gt;@sbchat&lt;/P&gt;&lt;P&gt;I had to unaccept the answer. What happens now is that the user is added, but the old users from the group are removed from it.&lt;/P&gt;&lt;P&gt;Can you check if this behaviour occurs on your side as well?
&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2016 19:27:54 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Adding-new-Ambari-user-with-assigned-group-with-API/m-p/166788#M37055</guid>
      <dc:creator>marko_kole</dc:creator>
      <dc:date>2016-08-05T19:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: Adding new Ambari user with assigned group with API</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Adding-new-Ambari-user-with-assigned-group-with-API/m-p/166789#M37056</link>
      <description>&lt;P&gt;So the answer to my question would be:&lt;/P&gt;&lt;P&gt;File add_to_group.amb:&lt;/P&gt;&lt;PRE&gt;{
  "MemberInfo/user_name":"user1",
  "MemberInfo/group_name":"group1"
}
&lt;/PRE&gt;&lt;PRE&gt;curl -iv -u admin:admin -H "X-Requested-By: ambari" -X PUT -d @add_to_group.amb  &lt;A href="http://ambari-server:8080/api/v1/groups/group1/members" target="_blank"&gt;http://ambari-server:8080/api/v1/groups/group1/members&lt;/A&gt;&lt;/PRE&gt;&lt;P&gt;This works! Thank you, &lt;A rel="user" href="https://community.cloudera.com/users/1902/sbhat.html" nodeid="1902"&gt;@sbhat&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2016 19:27:55 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Adding-new-Ambari-user-with-assigned-group-with-API/m-p/166789#M37056</guid>
      <dc:creator>marko_kole</dc:creator>
      <dc:date>2016-08-05T19:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: Adding new Ambari user with assigned group with API</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Adding-new-Ambari-user-with-assigned-group-with-API/m-p/166790#M37057</link>
      <description>&lt;P&gt;I made it work now. its not -X PUT but -X POST&lt;/P&gt;&lt;PRE&gt;curl -iv -u admin:admin -H "X-Requested-By: ambari" -X POST -d  '[{"MemberInfo/user_name":"user1", "MemberInfo/group_name":"group1"}]' &lt;A href="http://ambari-server:8080/api/v1/groups/group1/members" target="_blank"&gt;http://ambari-server:8080/api/v1/groups/group1/members&lt;/A&gt;&lt;/PRE&gt;&lt;P&gt;This adds new user to a group without deleting the existing group members.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2016 19:33:21 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Adding-new-Ambari-user-with-assigned-group-with-API/m-p/166790#M37057</guid>
      <dc:creator>marko_kole</dc:creator>
      <dc:date>2016-08-05T19:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: Adding new Ambari user with assigned group with API</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Adding-new-Ambari-user-with-assigned-group-with-API/m-p/166791#M37058</link>
      <description>&lt;P&gt;My assumption was this was a new group. Yes, POST would work for existing groups. &lt;/P&gt;</description>
      <pubDate>Fri, 05 Aug 2016 19:55:21 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Adding-new-Ambari-user-with-assigned-group-with-API/m-p/166791#M37058</guid>
      <dc:creator>sbhat</dc:creator>
      <dc:date>2016-08-05T19:55:21Z</dc:date>
    </item>
  </channel>
</rss>

