@@ -43,17 +43,6 @@ class RoleTypes(Enum):
4343 productAdmin = 2
4444
4545
46- class StepKeys (Enum ):
47- add = 1
48- addAdobeID = 2
49- addRoles = 3
50- createEnterpriseID = 4
51- remove = 5
52- removeFromOrg = 6
53- removeRoles = 7
54- update = 8
55-
56-
5746class IfAlreadyExistsOptions (Enum ):
5847 ignoreIfAlreadyExists = 1
5948 updateIfAlreadyExists = 2
@@ -328,40 +317,32 @@ def maybe_split_groups(self, max_groups):
328317 new_commands = []
329318 # return True if we split at least once
330319 maybe_split = False
320+ valid_step_keys = ['add' , 'addRoles' , 'remove' ]
331321 for command in self .commands :
322+ # commands are assumed to contain a single key
332323 step_key , step_args = next (six .iteritems (command ))
333- if step_key not in [ StepKeys . add . name , StepKeys . remove . name , StepKeys . addRoles . name ] :
324+ if step_key not in valid_step_keys :
334325 new_commands .append (command )
335326 continue
336- split_commands = self ._split_groups (step_key , command , max_groups )
337- if len (split_commands ) > 1 :
338- maybe_split = True
327+ split_commands = [command ]
328+ while True :
329+ new_command = {step_key : {}}
330+ if not isinstance (command [step_key ], dict ):
331+ break
332+ for group_type , groups in six .iteritems (command [step_key ]):
333+ if len (groups ) > max_groups :
334+ maybe_split = True
335+ command [step_key ][group_type ], new_command [step_key ][group_type ] = \
336+ groups [0 :max_groups ], groups [max_groups :]
337+ if new_command [step_key ]:
338+ split_commands .append (new_command )
339+ command = new_command
340+ else :
341+ break
339342 new_commands += split_commands
340343 self .commands = new_commands
341344 return maybe_split
342345
343- def _split_groups (self , step_key , command , max_groups ):
344- """
345- Split long group lists of individual command
346- Creates additional commands for each split and recursively splits new groups until no commands exceed group
347- limit. Assumes that at least one split should occur.
348- :param step_key: Step key (add, remove, etc)
349- :param command: Single command containing one or more group lists to add, remove, etc
350- :param max_groups: Max group list size
351- :return: List of at least two commands that resulted from split
352- """
353- new_commands = [command ]
354- while True :
355- new_command = {step_key : {}}
356- for group_type , groups in six .iteritems (command [step_key ]):
357- if len (groups ) > max_groups :
358- command [step_key ][group_type ], new_command [step_key ][group_type ] = \
359- groups [0 :max_groups ], groups [max_groups :]
360- if new_command [step_key ]:
361- new_commands += self ._split_groups (step_key , new_command , max_groups )
362- else :
363- return new_commands
364-
365346
366347class UsersQuery (QueryMultiple ):
367348 """
0 commit comments