Skip to content

Commit

Permalink
fix: remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
gcharest authored Apr 26, 2024
1 parent e600885 commit f96078e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 115 deletions.
39 changes: 0 additions & 39 deletions app/modules/provisioning/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,42 +40,3 @@ def get_groups_with_members_from_integration(integration_source, **kwargs):
for filter in filters:
groups = filter_tools.filter_by_condition(groups, filter)
return groups


# def get_matching_groups(source_groups, target_groups, matching_key):
# """Get the groups that match between the source and target groups.
# The function compares the groups in the source and target lists and returns the groups that match between them.

# Args:
# source_groups (list): A list containing the source groups data.
# target_groups (list): A list containing the target groups data.
# matching_key (str): The key to match between the source and target groups. For better performance, avoid using nested keys when possible.

# Returns:
# list: A list of groups that match between the source and target groups.
# """

# if not source_groups or not target_groups:
# return [], []

# source_values = {}
# for group in source_groups:
# value = filter_tools.get_nested_value(group, matching_key)
# if value is not None:
# source_values[value] = group

# target_values = {}
# for group in target_groups:
# value = filter_tools.get_nested_value(group, matching_key)
# if value is not None:
# target_values[value] = group

# if not source_values or not target_values:
# return [], []

# matching_values = set(source_values.keys()) & set(target_values.keys())

# filtered_source_groups = [source_values[value] for value in matching_values]
# filtered_target_groups = [target_values[value] for value in matching_values]

# return filtered_source_groups, filtered_target_groups
76 changes: 0 additions & 76 deletions app/modules/provisioning/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,79 +29,3 @@ def get_unique_users_from_groups(groups, key):
users_dict[str(user)] = user

return list(users_dict.values())


# def sync(source, target, **kwargs):
# """
# Sync users from source to target groups. The function compares the users in the source and target lists and returns the users to add/create and the users to remove/delete in the target list.

# Users to create are the ones that are in the source list but not in the target list.

# Users to delete are the ones that are in the target list but not in the source list.

# Args:
# source (dict): Source system data. Must contain the keys 'users' (list) and 'key' (string).
# target (dict): Target system data. Must contain the keys 'users' (list) and 'key' (string).
# **kwargs: Additional keyword arguments. Supported arguments are:

# - filters (list): List of filters to apply to the users.
# - enable_delete (bool): Enable the deletion of users in the target system.
# - delete_target_all (bool): Mark all target system users for deletion.

# Returns:
# tuple: A tuple containing the users to create and the users to delete in the target system.
# """

# source_key = source.get("key", None)
# target_key = target.get("key", None)
# source_users = source.get("users", None)
# target_users = target.get("users", None)
# enable_delete = kwargs.get("enable_delete", False)
# delete_target_all = kwargs.get("delete_target_all", False)

# logger.info(
# f"Syncing users from source to target.\nSource: {json.dumps(source, indent=2)}\nTarget: {json.dumps(target, indent=2)}"
# )

# # specifically handle the case where all the target system users should be deleted
# if delete_target_all:
# logger.warning("Marking all target system users for deletion.")
# return [], target_users

# # missing required data will result in no users to create or delete
# if not source_key or not target_key or not source_users:
# return [], []

# users_to_add = source_users.copy()

# logger.info(
# f"Syncing users from source ({len(source_users)}) to target ({len(target_users)})."
# )
# filters = kwargs.get("filters", [])
# for filter in filters:
# users_to_add = filter_tools.filter_by_condition(users_to_add, filter)

# target_users_keys = set(
# [filter_tools.get_nested_value(user, target_key) for user in target_users]
# )

# users_to_add = filter_tools.filter_by_condition(
# users_to_add,
# lambda user: filter_tools.get_nested_value(user, source_key)
# not in target_users_keys,
# )

# users_to_add_keys = set(
# [filter_tools.get_nested_value(user, source_key) for user in users_to_add]
# )

# users_to_remove = filter_tools.filter_by_condition(
# target_users,
# lambda user: filter_tools.get_nested_value(user, target_key)
# in users_to_add_keys,
# )

# if not enable_delete:
# users_to_remove = []

# return users_to_add, users_to_remove

0 comments on commit f96078e

Please sign in to comment.