This documentation relates to QuickBuild 6.1.x
Select here if you are using a different version

Interact with Group Memberships

Get all memberships in the system

Syntax

Memberships in the system can be accessed using http GET method through below url:

http://localhost:8810/rest/memberships

The response is of mime type application/xml and the content is XML representation of all memberships in the system.

Security

You will need to use http BASIC authentication to login as authorized QuickBuild user if the anonymous does not have adminstrative right.

Demo

Below curl command demonstrates how to get all memberships:

curl -u admin:admin http://localhost:8810/rest/memberships

Access membership by id

Syntax

Membership can be accessed by id using http GET method through below url:

http://localhost:8810/rest/memberships/<membership id>

The response is of mime type application/xml and the content is XML representation of the membership.

Security

You will need to use http BASIC authentication to login as authorized QuickBuild user if the anonymous does not have adminstrative right.

Demo

Below curl command demonstrates how to get membership of id 1:

curl -u admin:admin http://localhost:8810/rest/memberships/1

Access memberships of a particular user

Syntax

Memberships of particular user can be accessed using http GET method through below url:

http://localhost:8810/rest/memberships?user_id=<user id>

The response is of mime type application/xml and the content is XML representation of all memberships of specified user.

Security

You will need to use http BASIC authentication to login as authorized QuickBuild user if the anonymous does not have adminstrative right.

Demo

Below curl command demonstrates how to get memberships of user with id 2:

curl -u admin:admin http://localhost:8810/rest/memberships?user_id=2

Access memberships of a particular group

Syntax

Memberships of particular group can be accessed using http GET method through below url:

http://localhost:8810/rest/memberships?group_id=<group id>

The response is of mime type application/xml and the content is XML representation of all memberships of specified group.

Security

You will need to use http BASIC authentication to login as authorized QuickBuild user if the anonymous does not have adminstrative right.

Demo

Below curl command demonstrates how to get memberships of group with id 1:

curl -u admin:admin http://localhost:8810/rest/memberships?group_id=1

Update membership

Syntax

Membership can be updated by posting xml representation of the membership to below url:

http://localhost:8810/rest/memberships

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.

Security

You will need to use http BASIC authentication to login as administrator if the anonymous does not have administrative right.

Demo

We will use curl to demonstrate how to move user robin from developer group to tester group:

  1. 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.
  2. Run below command to get memberships of user robin:
    curl -u admin:admin http://localhost:8810/rest/memberships?user_id=2
  3. 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.
  4. Modify tempfile.xml and change the group element to use value of 2.
  5. Post content of tempfile.xml back to QuickBuild using below command:
    curl -X POST -u admin:admin -d@tempfile.xml http://localhost:8810/rest/memberships

Create membership

Syntax

Membership can be created by posting XML representation of the membership to below url:

http://localhost:8810/rest/memberships

A sample membership XML representation is like below:

<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>

The response is of mime type text/plain and the content is string representation of the newly created membership id.

Security

You will need to use http BASIC authentication to login as administrator if the anonymous does not have administrative right.

Demo

We will use curl to demonstrate how to add user robin (assume id is 2) to group tester (assume the id is 3).

  1. Save below content into file tempfile.xml:
    <com.pmease.quickbuild.model.Membership>
      <user>2</user>
      <group>3</group>
    </com.pmease.quickbuild.model.Membership>
    
  2. Post content of tempfile.xml to QuickBuild using below command:
    curl -X POST -u admin:admin -d@tempfile.xml http://localhost:8810/rest/memberships

Delete membership

Syntax

Membership can be deleted using http DELETE method through below url:

http://localhost:8810/rest/memberships/<membership id>

Here <membership id> stands for id of the membership to be deleted.

Security

You will need to use http BASIC authentication to login as administrator if the anonymous does not have administrative right.

Demo

Below curl command demonstrates how to remove user robin (assume id is 2) from group tester (assume the id is 3).

  1. Get memberships of user robin with below command:
    curl -u admin:admin http://localhost:8810/rest/memberships?user_id=2
  2. 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.
  3. Delete the found membership with below command:
    curl -X DELETE -u admin:admin http://localhost:8810/rest/memberships/100

Labels:

Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.