View Source

{info}Group share is the object used to control dashboard sharing with groups{info}

h1. Get all group shares in the system

h2. Syntax
Group shares in the system can be accessed using http GET method through below url:
{code}http://localhost:8810/rest/group_shares{code}
The response is of mime type _application/xml_ and the content is XML representation of all group shares in the system.

h2. Security
You will need to use http BASIC authentication to login as administrator.

h2. Demo
Below [curl|http://curl.haxx.se/] command demonstrates how to get all group shares:
{code}curl -u admin:admin http://localhost:8810/rest/group_shares{code}

{info}group share with no group information means to share with everyone{info}

h1. Access group share by id

h2. Syntax
Group share can be accessed by id using http GET method through below url:
{code}http://localhost:8810/rest/group_shares/<group_share id>{code}
The response is of mime type _application/xml_ and the content is XML representation of the group share.

h2. Security
You will need to use http BASIC authentication to login as administrator or user owning dashboard of the group share.

h2. Demo
Below [curl|http://curl.haxx.se/] command demonstrates how to get group share of id _1_:
{code}curl -u admin:admin http://localhost:8810/rest/group_shares/1{code}

h1. Access group shares of a particular dashboard

h2. Syntax
Group shares of particular dashboard can be accessed using http GET method through below url:
{code}http://localhost:8810/rest/group_shares?dashboard_id=<dashboard id>{code}
The response is of mime type _application/xml_ and the content is XML representation of all group shares of specified dashboard.

h2. Security
You will need to use http BASIC authentication to login as administrator or the user owning queried dashboard.

h2. Demo
Below [curl|http://curl.haxx.se/] command demonstrates how to get group shares of dashboard with id _2_:
{code}curl -u admin:admin http://localhost:8810/rest/group_shares?dashboard_id=2{code}

h1. Access group shares of a particular group

h2. Syntax
Group shares of particular group can be accessed using http GET method through below url:
{code}http://localhost:8810/rest/group_shares?group_id=<group id>{code}
Here <group id> represents id of the group to query group share information for. Particularly, use id _0_ to query group
shares targeting everyone.
The response is of mime type _application/xml_ and the content is XML representation of all group shares of specified group.

h2. Security
You will need to use http BASIC authentication to login as administrator.

h2. Demo
Below [curl|http://curl.haxx.se/] command demonstrates how to get group shares of group with id _1_:
{code}curl -u admin:admin http://localhost:8810/rest/group_shares?group_id=1{code}

h1. Update group share

h2. Syntax
Group share can be updated by posting xml representation of the group share to below url:
{code}http://localhost:8810/rest/group_shares{code}
Normally you do not need to create the XML from scratch: you may retrieve XML representation of the group share 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 group share id being updated.

h2. Security
You will need to use http BASIC authentication to login as administrator or user owning dashboard of the group share.

h2. Demo
We will use [curl|http://curl.haxx.se/] to demonstrate how to share dashboard _project1_ with _group1_ instead of _group2_:
# Assume id of dashboard _project1_ is _2_, id of group _group1_ is _1_, and id of group _group2_ is _2_. Ids of these entities can be accessed using [id service|retrieve object identifier].
# Run below command to get group shares of dashboard _project1_:
{code}curl -u admin:admin http://localhost:8810/rest/group_shares?dashboard_id=2{code}
# Analyze response of above command to find out the group share with group id _1_. Save xml snippet of found group share to a temp file, say _tempfile.xml_.
# 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 http://localhost:8810/rest/group_shares{code}

h1. Create group share

h2. Syntax
Group share can be created by posting XML representation of the group share to below url:
{code}http://localhost:8810/rest/group_shares{code}
A sample group share XML representation is like below:
{code}
<com.pmease.quickbuild.model.GroupShare>
<!-- id of associated group of this group share. If group element does not exist, QuickBuild will share the dashboard with everyone -->
<group>2</group>

<!-- id of associated dashboard of this group share. -->
<dashboard>1</dashboard>
</com.pmease.quickbuild.model.GroupShare>
{code}
The response is of mime type _text/plain_ and the content is string representation of the newly created group share id.

h2. Security
You will need to use http BASIC authentication to login as administrator or user owning dashboard of the group share.

h2. Demo
We will use [curl|http://curl.haxx.se/] to demonstrate how to share dashboard _project1_ (assume id is _2_) with group _group1_ (assume the id is _3_).
# Save below content into file _tempfile.xml_:
{code}
<com.pmease.quickbuild.model.GroupShare>
<dashboard>2</dashboard>
<group>3</group>
</com.pmease.quickbuild.model.GroupShare>
{code}
# Post content of _tempfile.xml_ to QuickBuild using below command:
{code}curl -X POST -u admin:admin -d@tempfile.xml http://localhost:8810/rest/group_shares{code}

h1. Delete group share

h2. Syntax
Group share can be deleted using http DELETE method through below url:
{code}http://localhost:8810/rest/group_shares/<group share id>{code}
Here _<group share id>_ stands for id of the group share to be deleted.

h2. Security
You will need to use http BASIC authentication to login as administrator or user owning dashboard of the group share.

h2. Demo
Below [curl|http://curl.haxx.se/] command demonstrates how to remove group _group1_ (assume id is _3_) from share list of dashboard _project1_ (assume the id is _2_).
# Get group shares of dashboard _project1_ with below command:
{code}curl -u admin:admin http://localhost:8810/rest/group_shares?dashboard_id=2{code}
# Analyze response of above command to find out id of the group share associated with group id _3_, assume id of the found group share is _100_.
# Delete the found group share with below command:
{code}curl -X DELETE -u admin:admin http://localhost:8810/rest/group_shares/100{code}