Remus Avram Posted August 2, 2016 Report Posted August 2, 2016 Hi all, how can I get the 'Roles' from Ftrack using the new API? Is it possible to add a new 'Role' to a user via the API? Cheers!
Mattias Lagergren Posted August 3, 2016 Report Posted August 3, 2016 Hi Remus, unfortunately the new ftrack-python-api currently lacks support for roles. It is something that we want to add but haven't got to yet
Remus Avram Posted August 3, 2016 Author Report Posted August 3, 2016 Hi Mattias, thanks for your answer! Then we will try to use the ftrack-python-api legacy for roles.
Remus Avram Posted August 5, 2016 Author Report Posted August 5, 2016 Is it possible to add a role to a user via the legacy API?
Mattias Lagergren Posted August 5, 2016 Report Posted August 5, 2016 You have a function: user.addRole(role, [project]) that can be used for role assignments in the legacy api
Remus Avram Posted August 5, 2016 Author Report Posted August 5, 2016 Is it possible to get all the roles via the API?
Mattias Lagergren Posted August 10, 2016 Report Posted August 10, 2016 On 8/5/2016 at 6:44 PM, Remus Avram said: Is it possible to get all the roles via the API? Not all roles, you can get all roles that a user has tough. Moving forward we will try to look at getting roles into the new API.
Björn Rydahl Posted December 15, 2016 Report Posted December 15, 2016 Roles can now be queried and managed for users from ftrack 3.3.36 using the ftrack python API. release notes: http://ftrack.rtd.ftrack.com/en/stable/release/release_notes.html Cheers
Remus Avram Posted December 15, 2016 Author Report Posted December 15, 2016 That is great! Thanks a lot! We will update to the latest version and check it.
Remus Avram Posted December 22, 2016 Author Report Posted December 22, 2016 We start testing it and we have a couple of issues: 1. Roles can be deleted even if they are in use. 2. Multiple roles can be created with the same name and type. 3. Roles can not be created via API: session.create('SecurityRole', {"name": name, "type": role_type}) ftrack_api.session.Session> ERROR | 2016/12/22 16:29:30.990 (MainThread)|Server reported error: TypeError('NoneType' object is not iterable) 4. Roles can not be deleted via API: session.delete(role) ftrack_api.session.Session> ERROR | 2016/12/22 17:54:27.930 (MainThread)|Server reported error: PermissionError(Permission denied: not allowed to 'delete' 'Auth_Role'. Operation 'delete' can never be done on 'Auth_Role'.) 5. Can not add and then get added roles in the same session: user = session.query("User where username is '%s'" % (username)).first() role = session.query("SecurityRole where name is '%s'" % (role_name)).first() is_all_projects = True project = None session.create('UserSecurityRole', {"user_id": user['id'], "is_all_projects": is_all_projects, "security_role_id": role['id'], "projects": projects}) session.commit() user = session.query("User where username is '%s'" % (username)).first() user_roles = user['user_security_roles'] print role in user_roles Result: False If I check in the Ftrack web interface the role is added to the user. 6. Can't get user security roles: session.query("UserSecurityRole").all() Result: raise ftrack_api.exception.ServerError(error_message) ServerError: Server reported error: KeyError(u'role_id') I think it should be security_role_id instead of role_id.
Mattias Lagergren Posted December 23, 2016 Report Posted December 23, 2016 Thank you for letting us now. Björn is on vacation over the holidays but I will forward this to him
Remus Avram Posted December 23, 2016 Author Report Posted December 23, 2016 Thank you Mattias! I will keep adding here issues (if I found more) regarding Roles.
Remus Avram Posted January 12, 2017 Author Report Posted January 12, 2017 Hi Mattias! Are there any updates regarding roles in the ftrack_api?
Björn Rydahl Posted January 13, 2017 Report Posted January 13, 2017 Hi Remus, we currently only support managing UserSecurityRoles via the API. So basically assigning existing roles to users. Regarding point 5, that is a misstake from our side in the schema. Will fix that and until then you can work around it by specifying what to query like this: session.query('select user_id, security_role_id from UserSecurityRole').all() to avoid it using the defaults which include a typo. And for 6, you should also explicitly query the relation to ensure it is being updates. "select user_security_roles from User" Let me know if that helps. Cheers
Remus Avram Posted October 2, 2017 Author Report Posted October 2, 2017 Hi @Björn Rydahl, any updates regarding the issue above? "5. Can not add and then get added roles in the same session:"
Mattias Lagergren Posted October 3, 2017 Report Posted October 3, 2017 Hi Remus, just to confirm does it help del it and query again: del user['user_security_roles']
Remus Avram Posted October 4, 2017 Author Report Posted October 4, 2017 No, It doesn't. Instead clearing the cache and querying the data again works. > print len(user['user_security_roles']) 2 > del user['user_security_roles'] > user = get_ftrack_user(username="unittest_artist") > print len(user['user_security_roles']) 2 > session.cache.clear() > user = get_ftrack_user(username="unittest_artist") > print len(user['user_security_roles']) 1
Mattias Lagergren Posted October 4, 2017 Report Posted October 4, 2017 Thank you for letting me know, I will ask a colleague to see if he can spot the reason for this issue.
Remus Avram Posted November 7, 2017 Author Report Posted November 7, 2017 Hi @Mattias Lagergren any updates regarding this issue?
Mattias Lagergren Posted November 8, 2017 Report Posted November 8, 2017 Hi Remus, we have found a potential issue and are working on a fix for this - hopefully we can get it resolved soon!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.