Skip to content

Commit

Permalink
Merge pull request #13 from Jordan-Prescott/auditing_aa_cc_hg
Browse files Browse the repository at this point in the history
Auditing aa cc hg
  • Loading branch information
Jordan-Prescott authored Feb 7, 2024
2 parents ebc7986 + fd2b762 commit 371655f
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
10 changes: 10 additions & 0 deletions odins_spear/methods/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,16 @@ def user_report(self, user_id: str):
# SERVICE PROVIDERS
# SERVICES

def user_services_assigned(self, user_id: str):
"""
Args:
user_id (str): _description_
"""
endpoint = f"/users/services/assigned?userId={user_id}"

return self.requester.get(endpoint)

def user_services(self, user_id: str):
"""Fetch all services assigned to a broadwrok entity, this can be
a user, AA, CC, or HG.
Expand Down
2 changes: 2 additions & 0 deletions odins_spear/scripter.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class Scripter:
def __init__(self, api) -> None:
self.api = api

def aa_cc_hg_audit(self, service_provider_id: str, group_id: str):
return scripts.aa_cc_hg_audit.main(self.api, service_provider_id, group_id)

# TODO: How will users be passed in
def bulk_enable_voicemail(self, users):
Expand Down
2 changes: 2 additions & 0 deletions odins_spear/scripts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
__all__ = [
"aa_cc_hg_audit",
"bulk_enable_voicemail",
"bulk_password_reset",
"find_alias",
Expand All @@ -8,6 +9,7 @@
"user_association"
]

from .aa_cc_hg_audit import main
from .bulk_enable_voicemail import main
from .bulk_password_reset import main
from .find_alias import main
Expand Down
64 changes: 64 additions & 0 deletions odins_spear/scripts/aa_cc_hg_audit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import json
from tqdm import tqdm

def remove_excess_details(aa_cc_hg: dict):
del aa_cc_hg["name"]
del aa_cc_hg["phoneNumber"]
del aa_cc_hg["extension"]
del aa_cc_hg["department"]
del aa_cc_hg["isActive"]

if aa_cc_hg["type_tag"] == "AA":
del aa_cc_hg["type"]
del aa_cc_hg["video"]
elif aa_cc_hg["type_tag"] == "CC":
del aa_cc_hg["video"]
del aa_cc_hg["policy"]
elif aa_cc_hg["type_tag"] == "HG":
del aa_cc_hg["serviceProviderId"]
del aa_cc_hg["groupId"]
del aa_cc_hg["policy"]

def main(api, service_provider_id: str, group_id: str):

print("aa_cc_hg_audit start.")
return_data = {
"Auto Attendants": [],
"Call Centres": [],
"Hunt Groups": []
}
auto_attendants = api.get.auto_attendants(service_provider_id, group_id)
call_centers = api.get.group_call_centers(service_provider_id, group_id)
hunt_groups = api.get.group_hunt_groups(service_provider_id, group_id)

for aa in tqdm(auto_attendants, desc="Analysing Auto Attendants"):
aa["type_tag"] = "AA"
remove_excess_details(aa)

for cc in tqdm(call_centers, desc="Analysing Call Centers"):
cc["type_tag"] = "CC"
remove_excess_details(cc)

for hg in tqdm(hunt_groups, desc="Analysing Hunt Groups"):
hg["type_tag"] = "HG"
remove_excess_details(hg)

aa_cc_hgs = auto_attendants + call_centers + hunt_groups

for aa_cc_hg in tqdm(aa_cc_hgs, desc="Fetching User Services"):
response = api.get.user_services_assigned(aa_cc_hg["serviceUserId"])
aa_cc_hg["services"] = response["userServices"]

if aa_cc_hg["type_tag"] == "AA":
del aa_cc_hg["type_tag"]
return_data["Auto Attendants"].append(aa_cc_hg)
elif aa_cc_hg["type_tag"] == "CC":
del aa_cc_hg["type_tag"]
return_data["Call Centres"].append(aa_cc_hg)
elif aa_cc_hg["type_tag"] == "HG":
del aa_cc_hg["type_tag"]
return_data["Hunt Groups"].append(aa_cc_hg)

return json.dumps(return_data)


0 comments on commit 371655f

Please sign in to comment.