dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32453
Re: Using /api/dashboards to assign user groups to dashboards
No, not really. But the API itself is quite simple, to get current sharing
information, you just do:
/api/sharing/type=dashboard&id=ID (GET request)
and then to update, you can use (PUT/POST request):
/api/sharing/type=dashboard&id=ID
With your JSON payload
It's probably easiest to just sniff on the POST with web inspector, and you
will get an idea of the API, for example I set external, added a group, and
set public read on a dashboard on our test server, and the resulting JSON
was:
{
"meta": {
"allowPublicAccess": true,
"allowExternalAccess": true
},
"object": {
"id": "iMnYyBfSxmM",
"name": "Delivery",
"publicAccess": "r-------",
"externalAccess": true,
"user": {
"id": "GOLswS44mh8",
"name": "Tom Wakiki"
},
"userGroupAccesses": [
{
"id": "wl5cDMuUhmF",
"name": "Administrators",
"access": "r-------"
}
]
}
}
The meta object you can just ignore, but the rest of the API should be
clear enough.
Please write back if you need more information, I don't think anyone else
is using the sharing API, so there might be some rough edges.
--
Morten
On Fri, Aug 29, 2014 at 2:14 PM, Sandesh Sukumar Doolipeta <
sandeshd@xxxxxxxxxxxxxxxx> wrote:
> Hi morten ,
>
> Thanks for the reply :) . Yes , I am okay with using two requests .
> Is there any documentation on the sharing api ? regarding its usage?
>
>
> On Fri, Aug 29, 2014 at 12:22 PM, Morten Olav Hansen <mortenoh@xxxxxxxxx>
> wrote:
>
>> Hi
>>
>> Are you OK with using two requests for this? we have a sharing API at
>> /api/sharing that will do what you want
>>
>> --
>> Morten
>>
>>
>> On Fri, Aug 29, 2014 at 3:10 AM, Sandesh Sukumar Doolipeta <
>> sandeshd@xxxxxxxxxxxxxxxx> wrote:
>>
>>> Hi ,
>>>
>>> We are trying to create dashboards using "/api/dashboards" api.
>>> While creating the dashboards , we also want to assign user groups to the
>>> dashboard.
>>>
>>> The following is the json being posted ,
>>> ======================
>>> {
>>> "displayName": "Chad",
>>> "name": "Chad",
>>> "dashboardItems": [
>>> {
>>> "chart": {
>>> "id": "36041e3ee38"
>>> }
>>> },
>>> {
>>> "chart": {
>>> "id": "e7f643ca378"
>>> }
>>> }
>>> ],
>>> "publicAccess": "--------",
>>> "access": {
>>> "read": true,
>>> "manage": true,
>>> "update": true,
>>> "externalize": true,
>>> "write": true,
>>> "delete": true
>>> },
>>> "externalAccess": false,
>>> "userGroupAccesses": [
>>> {
>>> "userGroup": {
>>> "id": "aede79b3fbf"
>>> }
>>> }
>>> ],
>>> "id": "abfd69cb586"
>>> }
>>> ==================
>>>
>>> Though the above json , creates the dashboard , it does not assign the
>>> user group to it.
>>>
>>> When I looked into the code ,
>>>
>>> I saw that , HibernateGenericStore.java is a work in progress ,
>>>
>>> ==========
>>>
>>> // TODO we might want to allow setting sharing props on save, but for
>>> now we null them out
>>> identifiableObject.setPublicAccess( null );
>>> identifiableObject.setUserGroupAccesses( new
>>> HashSet<UserGroupAccess>() );
>>>
>>> ==========
>>>
>>>
>>> Is there any other way to assign user groups to dashboard ? Am I
>>> missing anything ?
>>>
>>>
>>>
>>> --
>>> *Sandesh Doolipeta**Application Developer*
>>> Emailsandeshd@xxxxxxxxxxxxxxxx
>>> Telephone9686062727
>>> [image: ThoughtWorks] <http://www.thoughtworks.com/>
>>>
>>
>>
>
>
> --
> *Sandesh Doolipeta**Application Developer*
> Emailsandeshd@xxxxxxxxxxxxxxxx
> Telephone9686062727
> [image: ThoughtWorks] <http://www.thoughtworks.com/>
>
Follow ups
References