Was this page helpful?

Modify a Group's Role

    Description of the code sample

    The following command sets a group's (group ID = 1) role to the one listed in "grouprole.xml".

    Sample Code

    curl -u admin:password -H "Content-Type: application/xml" -T grouprole.xml -i http://192.l68.168.110/@api/deki/groups/1

    Implementation notes 

    curl flags

    -u
    Basic HTTP authentication. Sends a username and password to server so it can verify whether a user is of privilege to perform specific operation.
    -H
    Adds a header or modifies an existing one. In this case, since an xml document is being sent, the content type must be set to "application/xml". The server will not accept the request otherwise.
    -T file
    Specifies a PUT request and XML document that contains the user data.
    -i
    Includes the HTTP response header in the output. Useful for debugging.

    Permissions

    ADMIN permission is required to execute above command. Otherwise, a 403 HTTP response (Forbidden) will be returned.

     

    Example

    We want to modify the role of a group (group ID = 2) created here. Here are some of the roles that are packaged with MindTouch: Contributer, Viewer, Guest, and Admin. The group we wish to modify has the role of "Contributer". In this example, it will be changed to "Viewer".

    fabfour.xml

    Content-Type: application/xml

    <group>
        <permissions.group>
    	<role>Viewer</role>
        </permissions.group>
    </group>

    Command Line

    curl -u admin:password -H "Content-Type: application/xml" -T fabfourrole.xml -i http://192.168.168.110/@api/deki/groups/2

    HTTP Response Headers

    HTTP/1.1 200 OK
    Date: Thu, 14 Jan 2010 19:48:33 GMT
    Server: Dream-HTTPAPI/1.7.2.17433
    X-Deki-Site: id="default"
    Content-Type: application/xml; charset=utf-8
    Content-Length: 449
    Via: 1.1 dekiwiki
    

    HTTP Response Body

    Content-Type: application/xml

    <?xml version="1.0"?>
    <group id="2" href="http://192.168.168.110/@api/deki/groups/2">
      <groupname>the fab four</groupname>
      <service.authentication id="1" href="http://192.168.168.110/@api/deki/site/services/1"/>
      <users count="5" href="http://192.168.168.110/@api/deki/groups/2/users"/>
      <permissions.group>
        <operations mask="15">LOGIN,BROWSE,READ,SUBSCRIBE</operations>
        <role id="3" href="http://192.168.168.110/@api/deki/site/roles/3">Viewer</role>
      </permissions.group>
    </group>

    Notes

    Was this page helpful?
    Tag page
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by