Interact with Configuration Authorizations

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


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


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

View page history


There are 24 changes. View first change.

 h1. Access authorization by id
  h1. Get all authorizations in the system
  
 h2. Syntax
Authorization can be accessed by id using http GET method through below url:
 {code}http://localhost:8810/rest/authorization?id=<authorization id>{code}
 The response is of mime type _application/xml_ and the content is xml representation of the authorization.
  Authorizations in the system can be accessed using http GET method through below url:
 {code}http://localhost:8810/rest/authorizations{code}
 The response is of mime type _application/xml_ and the content is XML representation of all authorizations 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 authorization of id _1_:
 {code}curl -u admin:admin http://localhost:8810/rest/authorization?id=1{code}
  Below [curl|http://curl.haxx.se/] command demonstrates how to get all authorizations:
 {code}curl -u admin:admin http://localhost:8810/rest/authorizations{code}
  
h1. Access all authorizations in the system
  h1. Access authorization by id
  
 h2. Syntax
Authorizations in the system can be accessed using http GET method through below url:
 {code}http://localhost:8810/rest/authorizations{code}
 The response is of mime type _application/xml_ and the content is xml representation of list of authorizations in the system.
  Authorization can be accessed by id using http GET method through below url:
 {code}http://localhost:8810/rest/authorizations/<authorization id>{code}
 The response is of mime type _application/xml_ and the content is XML representation of the authorization.
  
 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 authorizations:
 {code}curl -u admin:admin http://localhost:8810/rest/authorizations{code}
  Below [curl|http://curl.haxx.se/] command demonstrates how to get authorization of id _1_:
 {code}curl -u admin:admin http://localhost:8810/rest/authorizations/1{code}
  
 
 h1. Access authorizations of a particular group
  
 h2. Syntax
 Authorizations of particular group can be accessed using http GET method through below url:
 {code}http://localhost:8810/rest/authorizations?group_id=<group id>{code}
The response is of mime type _application/xml_ and the content is xml representation of list of authorizations of specified group.
  The response is of mime type _application/xml_ and the content is XML representation of all authorizations 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 authorizations of group with id _2_:
 {code}curl -u admin:admin http://localhost:8810/rest/authorizations?group_id=2{code}
  
 h1. Access authorizations of a particular configuration
  
 h2. Syntax
 Authorizations of particular configuration can be accessed using http GET method through below url:
 {code}http://localhost:8810/rest/authorizations?configuration_id=<configuration id>{code}
The response is of mime type _application/xml_ and the content is xml representation of list of authorizations of specified configuration.
  The response is of mime type _application/xml_ and the content is XML representation of all authorizations of specified configuration.
  
 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 authorizations of configuration with id _1_:
 {code}curl -u admin:admin http://localhost:8810/rest/authorizations?configuration_id=1{code}
  
 h1. Update authorization
  
 h2. Syntax
 Authorization can be updated by posting xml representation of the authorization to below url:
{code}http://localhost:8810/rest/authorization{code}
 Normally you do not need to create the xml from scratch: you may retrieve xml representation of the authorization using http GET method, modify certain parts of the xml and post back to above url.
  {code}http://localhost:8810/rest/authorizations{code}
 Normally you do not need to create the XML from scratch: you may retrieve XML representation of the authorization 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 authorization 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 change authorization of group _developer_ from configuration _root/project1_ to _root/project2_:
# Assume id of group _developer_ is _1_, id of configuration _root/project1_ is _5_, and id of configurtion _root/project2_ is _6_. Ids of these entities can be parsed from the response xml returned by entity access APIs.
  # Assume id of group _developer_ is _1_, id of configuration _root/project1_ is _5_, and id of configurtion _root/project2_ is _6_. Ids of these entities can be retrieved with [id service|retrieve object identifier].
 # Run below command to get authorizations of group _developer_:
 {code}curl -u admin:admin http://localhost:8810/rest/authorizations?group_id=1{code}
 # Analyze response of above command to find out the authorization associated with configuration id _5_. Save xml snippet of found authorization to a temp file, say _tempfile.xml_.
# Modify _tempfile.xml_ and change the _configuration_ element to take value of _6_.
  # Modify _tempfile.xml_ and change the _configuration_ element to take value _6_.
 # 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/authorization{code}
  {code}curl -X POST -u admin:admin -d@tempfile.xml http://localhost:8810/rest/authorizations{code}
  
 h1. Create authorization
  
 h2. Syntax
Authorization can be created by posting xml representation of the authorization to below url:
 {code}http://localhost:8810/rest/authorization{code}
 Please note that the posted xml should NOT contain the id element; otherwise, QuickBuild will treat the post as an updating to the authorization with that id.
 Normally you do not need to create the xml from scratch: you may retrieve xml representation of a templating authorization using http GET method, remove the _id_ element, modify certain parts and post back to above url.
 The response is of mime type _text/plain_ and the content is string representation of id of the newly created authorization.
  Authorization can be created by posting XML representation of the authorization to below url:
 {code}http://localhost:8810/rest/authorizations{code}
 Please note that the posted XML should NOT contain the id element; otherwise, QuickBuild will treat the post as an updating to the authorization with that id.
 Normally you do not need to create the XML from scratch: you may retrieve XML representation of a templating authorization using http GET method, remove the _id_ element, modify certain parts and post back to above url.
 The response is of mime type _text/plain_ and the content is string representation of the newly created authorization 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 authorize group _tester_ (assume the id is _3_) with _RUN_BUILD_ and _STOP_BUILD_ permission in configuration _root/test_ (assume the id is _2_).
 # Save below content into file _tempfile.xml_:
 {code}
 <com.pmease.quickbuild.model.Authorization>
  <group>3</group>
  <configuration>3</configuration>
  <permissions>
  <string>RUN_BUILD</string>
  <string>STOP_BUILD</string>
  </permissions>
 </com.pmease.quickbuild.model.Authorization>
 {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/authorization{code}
  {code}curl -X POST -u admin:admin -d@tempfile.xml http://localhost:8810/rest/authorizations{code}
  
 h1. Delete authorization
  
 h2. Syntax
 Authorization can be deleted using http DELETE method through below url:
{code}http://localhost:8810/rest/authorization?id=<authorization id>{code}
  {code}http://localhost:8810/rest/authorizations/<authorization id>{code}
 Here _<authorization id}_ stands for id of the authorization 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 unauthorize configuration _root/test_ (assume id is _2_) for group _tester_ (assume the id is _3_).
 # Get authorizations of group _tester_ with below command:
 {code}curl -u admin:admin http://localhost:8810/rest/authorizations?group_id=3{code}
 # Analyze response of above command to find out id of the authorization associated with configuration id _2_, assume id of the found authorization is _100_.
 # Delete the found authorization with below command:
 {code}curl -X DELETE -u admin:admin http://localhost:8810/rest/authorization?id=100{code}
  {code}curl -X DELETE -u admin:admin http://localhost:8810/rest/authorizations/100{code}