Skip to content

Commit 9fff491

Browse files
committed
roles are long-deprecated
1 parent 44267de commit 9fff491

5 files changed

Lines changed: 6 additions & 79 deletions

File tree

tests/test_connections.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
from umapi_client import Connection
3232
from umapi_client import ArgumentError, UnavailableError, ServerError, RequestError
33-
from umapi_client import UserAction, GroupTypes, IdentityTypes, RoleTypes, UserGroupAction
33+
from umapi_client import UserAction, GroupTypes, IdentityTypes, UserGroupAction
3434
from umapi_client import __version__ as umapi_version
3535
from umapi_client.auth import JWTAuth
3636

@@ -456,15 +456,6 @@ def test_split_add_user():
456456
'user': 'user@example.com'}
457457

458458

459-
def test_split_role_assignment():
460-
group_prefix = "G"
461-
add_groups = [group_prefix+str(n+1) for n in range(0, 25)]
462-
user = UserAction(id_type=IdentityTypes.enterpriseID, email="user@example.com")
463-
user.add_role(groups=add_groups, role_type=RoleTypes.admin)
464-
assert user.maybe_split_groups(10) is True
465-
assert len(user.commands) == 3
466-
467-
468459
def test_no_group_split():
469460
"""
470461
maybe_split should return false if nothing was split

tests/test_functional.py

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from conftest import MockResponse
2626
from umapi_client import ArgumentError, RequestError
2727
from umapi_client import Connection
28-
from umapi_client import IdentityTypes, GroupTypes, RoleTypes
28+
from umapi_client import IdentityTypes, GroupTypes
2929
from umapi_client import UserAction, UserGroupAction
3030
from umapi_client import UsersQuery
3131

@@ -299,33 +299,6 @@ def test_remove_from_groups_federatedid_all_error():
299299
user.remove_from_groups(all_groups=True, group_type="usergroup")
300300

301301

302-
def test_add_role_enterpriseid():
303-
user = UserAction(id_type=IdentityTypes.enterpriseID, email="dbrotsky@o.on-the-side.net")
304-
user.add_role(groups=["Photoshop", "Illustrator"])
305-
assert user.wire_dict() == {"do": [{"addRoles": {"admin": ["Photoshop", "Illustrator"]}}],
306-
"user": "dbrotsky@o.on-the-side.net"}
307-
308-
309-
def test_add_role_enterpriseid_unicode():
310-
user = UserAction(id_type=IdentityTypes.enterpriseID, email="dbrotsky@o.on-the-side.net")
311-
user.add_role(groups=[u"người quản lý"])
312-
assert user.wire_dict() == {"do": [{"addRoles": {"admin": [u"người quản lý"]}}],
313-
"user": "dbrotsky@o.on-the-side.net"}
314-
315-
316-
def test_add_role_enterpriseid_error():
317-
user = UserAction(id_type=IdentityTypes.enterpriseID, email="dbrotsky@o.on-the-side.net")
318-
with pytest.raises(ValueError):
319-
user.add_role(groups=[], role_type=RoleTypes.admin)
320-
321-
322-
def test_remove_role_enterpriseid():
323-
user = UserAction(id_type='enterpriseID', email="dbrotsky@o.on-the-side.net")
324-
user.remove_role(groups=["Photoshop", "Illustrator"], role_type="productAdmin")
325-
assert user.wire_dict() == {"do": [{"removeRoles": {"productAdmin": ["Photoshop", "Illustrator"]}}],
326-
"user": "dbrotsky@o.on-the-side.net"}
327-
328-
329302
def test_remove_from_organization_federatedid():
330303
user = UserAction(id_type=IdentityTypes.federatedID, email="dbrotsky@k.on-the-side.net")
331304
user.remove_from_organization()

umapi_client/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from .auth import JWTAuth, OAuthS2S
2323
from .connection import Connection
2424
from .error import BatchError, ClientError, RequestError, ServerError, UnavailableError, ArgumentError
25-
from .functional import IdentityTypes, GroupTypes, RoleTypes, IfAlreadyExistsOptions
25+
from .functional import IdentityTypes, GroupTypes, IfAlreadyExistsOptions
2626
from .functional import UserAction, UserQuery, UsersQuery
2727
from .functional import UserGroupAction, UserGroupsQuery, GroupsQuery
2828
from .version import __version__

umapi_client/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def maybe_split_groups(self, max_groups):
134134
split_commands = []
135135
# return True if we split at least once
136136
maybe_split = False
137-
valid_step_keys = ['add', 'addRoles', 'remove']
137+
valid_step_keys = ['add', 'remove']
138138
for command in self.commands:
139139
# commands are assumed to contain a single key
140140
step_key, step_args = next(iter(command.items()))

umapi_client/functional.py

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,6 @@ class GroupTypes(Enum):
3939
group = 4
4040

4141

42-
class RoleTypes(Enum):
43-
admin = 1
44-
productAdmin = 2
45-
46-
4742
class IfAlreadyExistsOptions(Enum):
4843
ignoreIfAlreadyExists = 1
4944
updateIfAlreadyExists = 2
@@ -151,7 +146,7 @@ def add_to_groups(self, groups=None, all_groups=False, group_type=None):
151146
:param groups: list of group names the user should be added to
152147
:param all_groups: a boolean meaning add to all (don't specify groups or group_type in this case)
153148
:param group_type: the type of group (defaults to "group")
154-
:return: the User, so you can do User(...).add_to_groups(...).add_role(...)
149+
:return: the User, so you can do User(...).add_to_groups(...).???()
155150
"""
156151
if all_groups:
157152
if groups or group_type:
@@ -175,7 +170,7 @@ def remove_from_groups(self, groups=None, all_groups=False, group_type=None):
175170
:param groups: list of group names the user should be removed from
176171
:param all_groups: a boolean meaning remove from all (don't specify groups or group_type in this case)
177172
:param group_type: the type of group (defaults to "group")
178-
:return: the User, so you can do User(...).remove_from_groups(...).add_role(...)
173+
:return: the User, so you can do User(...).remove_from_groups(...).???(...)
179174
"""
180175
if all_groups:
181176
if groups or group_type:
@@ -193,38 +188,6 @@ def remove_from_groups(self, groups=None, all_groups=False, group_type=None):
193188
glist = {group_type.name: [group for group in groups]}
194189
return self.append(remove=glist)
195190

196-
def add_role(self, groups=None, role_type=RoleTypes.admin):
197-
"""
198-
Make user have a role (typically PLC admin) with respect to some PLC groups.
199-
:param groups: list of group names the user should have this role for
200-
:param role_type: the role (defaults to "admin")
201-
:return: the User, so you can do User(...).add_role(...).add_to_groups(...)
202-
"""
203-
if not groups:
204-
raise ArgumentError("You must specify groups to which to add the role for this user")
205-
if role_type in RoleTypes.__members__:
206-
role_type = RoleTypes[role_type]
207-
if role_type not in RoleTypes:
208-
raise ArgumentError("You must specify a RoleType value for argument role_type")
209-
glist = {role_type.name: [group for group in groups]}
210-
return self.append(addRoles=glist)
211-
212-
def remove_role(self, groups=None, role_type=RoleTypes.admin):
213-
"""
214-
Remove user from a role (typically admin) of some groups.
215-
:param groups: list of group names the user should NOT have this role for
216-
:param role_type: the type of role (defaults to "admin")
217-
:return: the User, so you can do User(...).remove_role(...).remove_from_groups(...)
218-
"""
219-
if not groups:
220-
raise ArgumentError("You must specify groups from which to remove the role for this user")
221-
if role_type in RoleTypes.__members__:
222-
role_type = RoleTypes[role_type]
223-
if role_type not in RoleTypes:
224-
raise ArgumentError("You must specify a RoleType value for argument role_type")
225-
glist = {role_type.name: [group for group in groups]}
226-
return self.append(removeRoles=glist)
227-
228191
def remove_from_organization(self, delete_account=False):
229192
"""
230193
Remove a user from the organization's list of visible users. Optionally also delete the account.

0 commit comments

Comments
 (0)