'PUT /api/groups/{encoded_group_id}
Modifies a group.'

@web.expose_api
@web.require_admin
def update(self, trans, id, payload, **kwd):

    group_id = id
    try:
        decoded_group_id = trans.security.decode_id(group_id)
    except TypeError:
        trans.response.status = 400
        return ('Malformed    group    id    (    %s    )    specified,    unable    to    decode.' % str(group_id))
    try:
        group = trans.sa_session.query(trans.app.model.Group).get(decoded_group_id)
    except:
        group = None
    if (not group):
        trans.response.status = 400
        return ('Invalid    group    id    (    %s    )    specified.' % str(group_id))
    name = payload.get('name', None)
    if name:
        group.name = name
        trans.sa_session.add(group)
    user_ids = payload.get('user_ids', [])
    users = [trans.sa_session.query(trans.model.User).get(trans.security.decode_id(i)) for i in user_ids]
    role_ids = payload.get('role_ids', [])
    roles = [trans.sa_session.query(trans.model.Role).get(trans.security.decode_id(i)) for i in role_ids]
    trans.app.security_agent.set_entity_group_associations(groups=[group], roles=roles, users=users, delete_existing_assocs=False)
    trans.sa_session.flush()
