Interact with Group Memberships

Version 1 by Robin Shen
on Dec 24, 2009 08:09.


 
compared with
Current by Robin Shen
on Jun 10, 2010 14:22.


 
Key
These lines were removed. This word was removed.
These lines were added. This word was added.

View page history


There are 25 changes. View first change.

 h1. Access membership by id
  h1. Get all memberships in the system
  
 h2. Syntax
Membership can be accessed by id using http GET method through below url:
 {code}http://localhost:8810/rest/membership?id=<membership id>{code}
 The response is of mime type _application/xml_ and the content is xml representation of the membership.
  Memberships in the system can be accessed using http GET method through below url:
 {code}http://localhost:8810/rest/memberships{code}
 The response is of mime type _application/xml_ and the content is XML representation of all memberships in the system.
  
 h2. Security
You will need to use http BASIC authentication to login as authorized QuickBuild user if the anonymous does not have adminstrative rights.
  You will need to use http BASIC authentication to login as authorized QuickBuild user if the anonymous does not have adminstrative right.
  
 h2. Demo
Below [curl|http://curl.haxx.se/] command demonstrates how to get membership of id _1_:
 {code}curl -u admin:admin http://localhost:8810/rest/membership?id=1{code}
  Below [curl|http://curl.haxx.se/] command demonstrates how to get all memberships:
 {code}curl -u admin:admin http://localhost:8810/rest/memberships{code}
  
h1. Access all memberships in the system
  h1. Access membership by id
  
 h2. Syntax
Memberships in the system can be accessed using http GET method through below url:
 {code}http://localhost:8810/rest/memberships{code}
 The response is of mime type _application/xml_ and the content is xml representation of list of memberships in the system.
  Membership can be accessed by id using http GET method through below url:
 {code}http://localhost:8810/rest/memberships/<membership id>{code}
 The response is of mime type _application/xml_ and the content is XML representation of the membership.
  
 h2. Security
You will need to use http BASIC authentication to login as authorized QuickBuild user if the anonymous does not have adminstrative rights.
  You will need to use http BASIC authentication to login as authorized QuickBuild user if the anonymous does not have adminstrative right.
  
 h2. Demo
Below [curl|http://curl.haxx.se/] command demonstrates how to get all memberships:
 {code}curl -u admin:admin http://localhost:8810/rest/memberships{code}
  Below [curl|http://curl.haxx.se/] command demonstrates how to get membership of id _1_:
 {code}curl -u admin:admin http://localhost:8810/rest/memberships/1{code}
  
 
 h1. Access memberships of a particular user
  
 h2. Syntax
 Memberships of particular user can be accessed using http GET method through below url:
 {code}http://localhost:8810/rest/memberships?user_id=<user id>{code}
The response is of mime type _application/xml_ and the content is xml representation of list of memberships of specified user.
  The response is of mime type _application/xml_ and the content is XML representation of all memberships of specified user.
  
 h2. Security
You will need to use http BASIC authentication to login as authorized QuickBuild user if the anonymous does not have adminstrative rights.
  You will need to use http BASIC authentication to login as authorized QuickBuild user if the anonymous does not have adminstrative right.
  
 h2. Demo
 Below [curl|http://curl.haxx.se/] command demonstrates how to get memberships of user with id _2_:
 {code}curl -u admin:admin http://localhost:8810/rest/memberships?user_id=2{code}
  
 h1. Access memberships of a particular group
  
 h2. Syntax
 Memberships of particular group can be accessed using http GET method through below url:
{code}http://localhost:8810/rest/memberships?group_id=<user id>{code}
 The response is of mime type _application/xml_ and the content is xml representation of list of memberships of specified group.
  {code}http://localhost:8810/rest/memberships?group_id=<group id>{code}
 The response is of mime type _application/xml_ and the content is XML representation of all memberships of specified group.
  
 h2. Security
You will need to use http BASIC authentication to login as authorized QuickBuild user if the anonymous does not have adminstrative rights.
  You will need to use http BASIC authentication to login as authorized QuickBuild user if the anonymous does not have adminstrative right.
  
 h2. Demo
 Below [curl|http://curl.haxx.se/] command demonstrates how to get memberships of group with id _1_:
 {code}curl -u admin:admin http://localhost:8810/rest/memberships?group_id=1{code}
  
 h1. Update membership
  
 h2. Syntax
 Membership can be updated by posting xml representation of the membership to below url:
{code}http://localhost:8810/rest/membership{code}
 Normally you do not need to create the xml from scratch: you may retrieve xml representation of the membership using http GET method, modify certain parts of the xml and post back to above url.
  {code}http://localhost:8810/rest/memberships{code}
 Normally you do not need to create the XML from scratch: you may retrieve XML representation of the membership using http GET method, modify certain parts of the XML and post back to above url.
 The response is of mime type _text/plain_ and the content is string representation of the membership id being updated.
  
 h2. Security
You will need to use http BASIC authentication to login as administrator if the anonymous does not have administrative rights.
  You will need to use http BASIC authentication to login as administrator if the anonymous does not have administrative right.
  
 h2. Demo
 We will use [curl|http://curl.haxx.se/] to demonstrate how to move user _robin_ from _developer_ group to _tester_ group:
# Assume id of user _robin_ is _2_, id of group _developer_ is _1_, and id of group _tester_ is _2_. Ids of these entities can be parsed from the response xml returned by entity access APIs.
  # Assume id of user _robin_ is _2_, id of group _developer_ is _1_, and id of group _tester_ is _2_. Ids of these entities can be accessed using [id service|retrieve object identifier].
 # Run below command to get memberships of user _robin_:
 {code}curl -u admin:admin http://localhost:8810/rest/memberships?user_id=2{code}
 # Analyze response of above command to find out the membership with group id _1_. Save xml snippet of found membership to a temp file, say _tempfile.xml_.
# Modify _tempfile.xml_ and change the _group_ element to take value of _2_.
  # Modify _tempfile.xml_ and change the _group_ element to use value of _2_.
 # Post content of _tempfile.xml_ back to QuickBuild using below command:
{code}curl -X POST -u admin:admin -d @tempfile.xml -u admin:admin http://localhost:8810/rest/membership{code}
  {code}curl -X POST -u admin:admin -d@tempfile.xml http://localhost:8810/rest/memberships{code}
  
 h1. Create membership
  
 h2. Syntax
Membership can be created by posting xml representation of the membership to below url:
 {code}http://localhost:8810/rest/membership{code}
 A sample membership xml representation is like below:
  Membership can be created by posting XML representation of the membership to below url:
 {code}http://localhost:8810/rest/memberships{code}
 A sample membership XML representation is like below:
 {code}
 <com.pmease.quickbuild.model.Membership>
  <!-- id of associated user of this membership. -->
  <user>2</user>
  
  <!-- id of associated group of this membership. -->
  <group>1</group>
 </com.pmease.quickbuild.model.Membership>
 {code}
The response is of mime type _text/plain_ and the content is string representation of id of the newly created membership.
  The response is of mime type _text/plain_ and the content is string representation of the newly created membership id.
  
 h2. Security
You will need to use http BASIC authentication to login as administrator if the anonymous does not have administrative rights.
  You will need to use http BASIC authentication to login as administrator if the anonymous does not have administrative right.
  
 h2. Demo
 We will use [curl|http://curl.haxx.se/] to demonstrate how to add user _robin_ (assume id is _2_) to group _tester_ (assume the id is _3_).
 # Save below content into file _tempfile.xml_:
 {code}
 <com.pmease.quickbuild.model.Membership>
  <user>2</user>
  <group>3</group>
 </com.pmease.quickbuild.model.Membership>
 {code}
 # Post content of _tempfile.xml_ to QuickBuild using below command:
{code}curl -X POST -u admin:admin -d @tempfile.xml -u admin:admin http://localhost:8810/rest/membership{code}
  {code}curl -X POST -u admin:admin -d@tempfile.xml http://localhost:8810/rest/memberships{code}
  
 h1. Delete membership
  
 h2. Syntax
 Membership can be deleted using http DELETE method through below url:
{code}http://localhost:8810/rest/membership?id=<membership id>{code}
 Here _<membership id}_ stands for id of the membership to be deleted.
  {code}http://localhost:8810/rest/memberships/<membership id>{code}
 Here _<membership id>_ stands for id of the membership to be deleted.
  
 h2. Security
You will need to use http BASIC authentication to login as administrator if the anonymous does not have administrative rights.
  You will need to use http BASIC authentication to login as administrator if the anonymous does not have administrative right.
  
 h2. Demo
 Below [curl|http://curl.haxx.se/] command demonstrates how to remove user _robin_ (assume id is _2_) from group _tester_ (assume the id is _3_).
 # Get memberships of user _robin_ with below command:
 {code}curl -u admin:admin http://localhost:8810/rest/memberships?user_id=2{code}
 # Analyze response of above command to find out id of the membership associated with group id _3_, assume id of the found membership is _100_.
 # Delete the found membership with below command:
 {code}curl -X DELETE -u admin:admin http://localhost:8810/rest/membership?id=100{code}
  {code}curl -X DELETE -u admin:admin http://localhost:8810/rest/memberships/100{code}