diff --git a/odins_spear/methods/get.py b/odins_spear/methods/get.py index e727ee1..647acc6 100644 --- a/odins_spear/methods/get.py +++ b/odins_spear/methods/get.py @@ -1,17 +1,23 @@ from ..utils.formatting import format_filter_value from ..exceptions import * -class Get(): + +class Get: filters = [ - "macAddress", "lastName", "firstName", "dn", - "emailAddress", "userId", "extension" + "macAddress", + "lastName", + "firstName", + "dn", + "emailAddress", + "userId", + "extension", ] def __init__(self, requester): self.requester = requester -#SESSION + # SESSION def session(self): @@ -19,13 +25,13 @@ def session(self): return self.requester.get(endpoint) -#ACCOUNT AUTHORIZATION CODES -#ADMINISTRATORS -#ADVICE OF CHARGE -#ALTERNATE NUMBERS + # ACCOUNT AUTHORIZATION CODES + # ADMINISTRATORS + # ADVICE OF CHARGE + # ALTERNATE NUMBERS def user_alternate_numbers(self, user_id: str): - """Fetches a list of a user/ service such as Auto Attendant, Hunt Group, or Call Centres + """Fetches a list of a user/ service such as Auto Attendant, Hunt Group, or Call Centres alternate numebrs. Args: @@ -34,22 +40,20 @@ def user_alternate_numbers(self, user_id: str): Returns: Dict: List of all alternate numbers assigned to the user/ service. """ - + endpoint = "/users/alternate-numbers" - - params = { - "userId": user_id - } + + params = {"userId": user_id} return self.requester.get(endpoint, params=params) -#ANSWER CONFIRMATION -#ALTERNATE USER ID -#ANNOUNCEMENTS -#ANONYMOUS CALL REJECTION -#ATTENDANT CONSOLE -#AUTHENTICATION -#AUTO ATTENDANTS + # ANSWER CONFIRMATION + # ALTERNATE USER ID + # ANNOUNCEMENTS + # ANONYMOUS CALL REJECTION + # ATTENDANT CONSOLE + # AUTHENTICATION + # AUTO ATTENDANTS def auto_attendants(self, service_provider_id: str, group_id: str): """Returns a complete list of all Auto Attendants in a single group. @@ -64,10 +68,7 @@ def auto_attendants(self, service_provider_id: str, group_id: str): endpoint = "/groups/auto-attendants" - params = { - "serviceProviderId": service_provider_id, - "groupId": group_id - } + params = {"serviceProviderId": service_provider_id, "groupId": group_id} return self.requester.get(endpoint, params=params) @@ -83,36 +84,34 @@ def auto_attendant(self, service_user_id: str): endpoint = "/groups/auto-attendants" - params = { - "serviceUserId": service_user_id - } + params = {"serviceUserId": service_user_id} return self.requester.get(endpoint, params=params) - - def auto_attendant_user(self, service_provider_id: str, group_id: str, user_id: str): + def auto_attendant_user( + self, service_provider_id: str, group_id: str, user_id: str + ): """Returns detailed information about all Auto Attendants (AA) built in the same group as the specified user. Args: - service_provider_id (str): Service Provider ID of the group where the user is built. + service_provider_id (str): Service Provider ID of the group where the user is built. group_id (str): Group ID of the group where the user is built. user_id (str): User ID of the user being queried. Returns: - List: Returns a list of the AAs built in the group. + List: Returns a list of the AAs built in the group. """ endpoint = "/groups/auto-attendants/user" params = { - "userId": user_id, - "serviceProviderId": service_provider_id, - "groupId": group_id + "userId": user_id, + "serviceProviderId": service_provider_id, + "groupId": group_id, } return self.requester.get(endpoint, params=params) - def auto_attendant_submenus(self, service_user_id: str): """Returns a list of the submenus of the specified Auto Attendant (AA). Works with Standard AAs only, basic AAs do not have submenus. @@ -125,46 +124,40 @@ def auto_attendant_submenus(self, service_user_id: str): endpoint = "/groups/auto-attendants/submenus" - params = { - "serviceUserId": service_user_id - } + params = {"serviceUserId": service_user_id} return self.requester.get(endpoint, params=params) - def auto_attendant_submenu_usage(self, service_user_id: str, submenu_id: str): - """Returns the type of the specified Auto Attendant (AA) submenu. NOTE: This method does not return any usage data. + """Returns the type of the specified Auto Attendant (AA) submenu. NOTE: This method does not return any usage data. Args: service_user_id (str): The service user ID of the AA being queried. - submenu_id (str): The submenu ID of the submenu being queried. + submenu_id (str): The submenu ID of the submenu being queried. Returns: - List: Returns a list containing a single dict of the submenu. + List: Returns a list containing a single dict of the submenu. """ endpoint = "/groups/auto-attendants/submenus/usage" - params = { - "serviceUserId": service_user_id, - "submenuId": submenu_id - } + params = {"serviceUserId": service_user_id, "submenuId": submenu_id} return self.requester.get(endpoint, params=params) -#AUTOMATIC CALLBACK -#AUTOMATIC HOLD RETRIEVE -#BARGE IN EXEMPT -#BASIC CALL LOGS -#BROADWORKS ANYWHERE -#BROADWORKS MOBILITY -#BROADWORKS NAVIGATION -#BROADWORKS RECEPTIONIST ENTERPRISE -#BROADWORKS RECEPTIONIST OFFICE -#BROADWORKS RECEPTIONIST SMALL BUSINESS -#BUSY LAMP FIELD -#CALL CAPACITY -#CALL CENTER + # AUTOMATIC CALLBACK + # AUTOMATIC HOLD RETRIEVE + # BARGE IN EXEMPT + # BASIC CALL LOGS + # BROADWORKS ANYWHERE + # BROADWORKS MOBILITY + # BROADWORKS NAVIGATION + # BROADWORKS RECEPTIONIST ENTERPRISE + # BROADWORKS RECEPTIONIST OFFICE + # BROADWORKS RECEPTIONIST SMALL BUSINESS + # BUSY LAMP FIELD + # CALL CAPACITY + # CALL CENTER def group_call_centers(self, service_provider_id: str, group_id: str): """Retrieves a list of active call centers within a specified group, along with their settings. @@ -178,13 +171,9 @@ def group_call_centers(self, service_provider_id: str, group_id: str): """ endpoint = "/groups/call-centers" - params = { - "serviceProviderId": service_provider_id, - "groupId": group_id - } + params = {"serviceProviderId": service_provider_id, "groupId": group_id} return self.requester.get(endpoint, params=params) - def group_call_center(self, service_user_id: str): """Retrieves deatiled information on a single Call Center. @@ -197,13 +186,10 @@ def group_call_center(self, service_user_id: str): endpoint = "/groups/call-centers" - params = { - "serviceUserId": service_user_id - } + params = {"serviceUserId": service_user_id} return self.requester.get(endpoint, params=params) - def user_call_center(self, user_id: str): """Retrieves a list of call centers that the specified user is currently associated with. @@ -216,14 +202,10 @@ def user_call_center(self, user_id: str): endpoint = "/users/call-center" - params = { - "userId": user_id - } - + params = {"userId": user_id} + return self.requester.get(endpoint, params=params) - - - + def group_call_center_agents(self, service_user_id: str): """Returns list of agents assigned to the target call center. @@ -233,16 +215,13 @@ def group_call_center_agents(self, service_user_id: str): Returns: Dict: List of agents assigned to call center """ - + endpoint = "/groups/call-centers/agents" - - params = { - "serviceUserId": service_user_id - } - + + params = {"serviceUserId": service_user_id} + return self.requester.get(endpoint, params=params) - - + def group_call_center_agents(self, service_user_id: str): """Returns list of agents assigned to the target call center. @@ -252,16 +231,13 @@ def group_call_center_agents(self, service_user_id: str): Returns: Dict: List of agents assigned to call center """ - + endpoint = "/groups/call-centers/agents" - - params = { - "serviceUserId": service_user_id - } - + + params = {"serviceUserId": service_user_id} + return self.requester.get(endpoint, params=params) - - + def group_call_center_bounced_calls(self, service_user_id: str): """Retrieves the number of rings before a call is bounced from the specified call center. @@ -271,16 +247,13 @@ def group_call_center_bounced_calls(self, service_user_id: str): Returns: Dict: Amount of Rings before a call is Bounced """ - + endpoint = "/groups/call-centers/bounced-calls" - - params = { - "serviceUserId": service_user_id - } + + params = {"serviceUserId": service_user_id} return self.requester.get(endpoint, params=params) - - + def group_call_center_forced_forwarding(self, service_user_id: str): """Retrieves the forwarding number for a call center if it is set to forward calls, along with any associated audio messages. @@ -290,16 +263,13 @@ def group_call_center_forced_forwarding(self, service_user_id: str): Returns: Dict: Number to be Forwarded to, alongside any Audio Messages. """ - + endpoint = "/groups/call-centers/forced-forwarding" - - params = { - "serviceUserId": service_user_id - } + + params = {"serviceUserId": service_user_id} return self.requester.get(endpoint, params=params) - def group_call_center_overflow(self, service_user_id): """Retrieves the forwarding number for a user when all call center agents are busy, along with any associated audio messages. @@ -309,16 +279,13 @@ def group_call_center_overflow(self, service_user_id): Returns: Dict: Dict: Call Centers overflow configuration. """ - + endpoint = "/groups/call-centers/overflow" - - params = { - "serviceUserId": service_user_id - } + + params = {"serviceUserId": service_user_id} return self.requester.get(endpoint, params=params) - - + def group_call_center_stranded_calls(self, service_user_id): """Retrieves the forwarding number for a user when a call center doesn't answer, along with any associated audio messages. @@ -328,16 +295,13 @@ def group_call_center_stranded_calls(self, service_user_id): Returns: Dict: Call Centers stranded call configuration. """ - + endpoint = "/groups/call-centers/stranded-calls" - - params = { - "serviceUserId": service_user_id - } + + params = {"serviceUserId": service_user_id} return self.requester.get(endpoint, params=params) - - + def group_call_center_stranded_calls_unavailable(self, service_user_id): """Retrieves the forwarding number for a user when a call center doesn't answer, along with the count of agents with an unavailable code in the call center. @@ -347,20 +311,17 @@ def group_call_center_stranded_calls_unavailable(self, service_user_id): Returns: Dict: Number to be Forwarded to, and Agents with an Unavailable Code set. """ - + endpoint = "/groups/call-centers/stranded-calls-unavailable" - - params = { - "serviceUserId": service_user_id - } + + params = {"serviceUserId": service_user_id} return self.requester.get(endpoint, params=params) - -#CALL CONTROL -#CALL FORWARDING ALWAYS - def user_call_forwarding_always(self, user_id: str): + # CALL CONTROL + # CALL FORWARDING ALWAYS + def user_call_forwarding_always(self, user_id: str): """Retrieves the Forwarding Always status for the specified User. Args: @@ -369,18 +330,14 @@ def user_call_forwarding_always(self, user_id: str): Returns: Dict: Forwarding enabled status, and the Number to be Forwarded to. """ - + endpoint = "/users/call-forwarding-always" - - params = { - "userId": user_id - } - return self.requester.get(endpoint, params=params) - - - def bulk_call_forwarding_always(self, service_provider_id: str, group_id: str): + params = {"userId": user_id} + + return self.requester.get(endpoint, params=params) + def bulk_call_forwarding_always(self, service_provider_id: str, group_id: str): """Retrieves the Forwarding Always status for all users within a specified group. Args: @@ -390,18 +347,14 @@ def bulk_call_forwarding_always(self, service_provider_id: str, group_id: str): Returns: List: Forwarding enabled status, the Number to be Forwarded to, and User information. """ - + endpoint = "/users/call-forwarding-always/bulk" - - params = { - "serviceProviderId": service_provider_id, - "groupId": group_id - } - return self.requester.get(endpoint, params=params) + params = {"serviceProviderId": service_provider_id, "groupId": group_id} + return self.requester.get(endpoint, params=params) -#CALL FORWARDING BUSY + # CALL FORWARDING BUSY def user_call_forwarding_busy(self, user_id: str): """Retrieves the Forwarding Not Reachable status for the specified user. @@ -412,39 +365,32 @@ def user_call_forwarding_busy(self, user_id: str): Returns: Dict: Forwarding enabled status, and the Number to be Forwarded to. """ - + endpoint = "/users/call-forwarding-busy" - - params = { - "userId": user_id - } + + params = {"userId": user_id} return self.requester.get(endpoint, params=params) - - + def bulk_call_forwarding_busy(self, service_provider_id: str, group_id: str): """Retrieves the Forwarding Busy status for all users within a specified group. Args: service_provider_id (str): Target Service Provider where group is hosted group_id (str): Target Group ID - + Returns: List: Forwarding enabled status, the Number to be Forwarded to, and User information. """ - + endpoint = "/users/call-forwarding-busy/bulk" - - params = { - "serviceProviderId": service_provider_id, - "groupId": group_id - } - return self.requester.get(endpoint, params=params) + params = {"serviceProviderId": service_provider_id, "groupId": group_id} + return self.requester.get(endpoint, params=params) -#CALL FORWARDING NO ANSWER + # CALL FORWARDING NO ANSWER def user_call_forwarding_no_answer(self, user_id: str): """Retrieves the Forwarding No Answer status for the specified user @@ -455,39 +401,32 @@ def user_call_forwarding_no_answer(self, user_id: str): Returns: Dict: Forwarding enabled status, and the Number to be Forwarded to. """ - + endpoint = "/users/call-forwarding-no-answer" - - params = { - "userId": user_id - } + + params = {"userId": user_id} return self.requester.get(endpoint, params=params) - - + def bulk_call_forwarding_no_answer(self, service_provider_id: str, group_id: str): """Retrieves the Forwarding No Answer status for all users within a specified group. Args: service_provider_id (str): Target Service Provider where group is hosted group_id (str): Target Group ID - + Returns: List: Forwarding enabled status, the Number to be Forwarded to, and User information. """ - + endpoint = "/users/call-forwarding-no-answer/bulk" - - params = { - "serviceProviderId": service_provider_id, - "groupId": group_id - } - return self.requester.get(endpoint, params=params) + params = {"serviceProviderId": service_provider_id, "groupId": group_id} + return self.requester.get(endpoint, params=params) -#CALL FORWARDING NOT REACHABLE + # CALL FORWARDING NOT REACHABLE def user_call_forwarding_not_reachable(self, user_id: str): """Retrieves the Forwarding Not Reachable status for the specified user @@ -498,101 +437,87 @@ def user_call_forwarding_not_reachable(self, user_id: str): Returns: Dict: Forwarding enabled status, and the Number to be Forwarded to. """ - + endpoint = "/users/call-forwarding-not-reachable" - - params = { - "userId": user_id - } + + params = {"userId": user_id} return self.requester.get(endpoint, params=params) - - - def bulk_call_forwarding_not_reachable(self, service_provider_id: str, group_id: str): + + def bulk_call_forwarding_not_reachable( + self, service_provider_id: str, group_id: str + ): """Retrieves the Forwarding Not Reachable status for all users within a specified group. Args: service_provider_id (str): Target Service Provider where group is hosted group_id (str): Target Group ID - + Returns: List: Forwarding enabled status, the Number to be Forwarded to, and User information. """ - + endpoint = "/users/call-forwarding-not-reachable/bulk" - - params = { - "serviceProviderId": service_provider_id, - "groupId": group_id - } - return self.requester.get(endpoint, params=params) + params = {"serviceProviderId": service_provider_id, "groupId": group_id} + return self.requester.get(endpoint, params=params) -#CALL FORWARDING SELECTIVE + # CALL FORWARDING SELECTIVE def user_call_forwarding_selective(self, user_id: str): """Retrieves the Forwarding Selective status for a specified User, alongside the criteria. Args: user_id (str): Target User ID - + Returns: Dict: Forwarding enabled status and the Forwarding criteria. """ - + endpoint = "/users/call-forwarding-selective" - - params = { - "userId": user_id - } + + params = {"userId": user_id} return self.requester.get(endpoint, params=params) - - + def user_call_forwarding_selective_criterias(self, user_id: str): """Retrieves the Forwarding Selective status for a specified User, alongside the criteria's assigned. Args: user_id (str): Target User ID - + Returns: Dict: Forwarding enabled status and the Forwarding criteria's names and settings. """ - + endpoint = "/users/call-forwarding-selective/criteria" - - params = { - "userId": user_id - } + + params = {"userId": user_id} return self.requester.get(endpoint, params=params) - - + def user_call_forwarding_selective_criteria(self, user_id: str, criteria_name: str): """Retrieves the Forwarding Selective status for a specified User, alongside the specified Criteria Args: user_id (str): Target User ID criteria_name (str): Target Criteria Name - + Returns: Dict: Forwarding enabled status and the specified Criterias Settings. """ - + endpoint = "/users/call-forwarding-selective/criteria" - - params = { - "criteriaName": criteria_name, - "userId": user_id - } - + + params = {"criteriaName": criteria_name, "userId": user_id} + return self.requester.get(endpoint, params=params) -#CALL NOTIFY -#CALL PARK -#CALL PICKUP + # CALL NOTIFY + # CALL PARK + # CALL PICKUP def call_pickup_group_user(self, service_provider_id, group_id, user_id): """Retrieves Pickup Group information for the specified user. @@ -601,7 +526,7 @@ def call_pickup_group_user(self, service_provider_id, group_id, user_id): service_provider_id (str): Target Service Provider ID group_id (str): The Target Group ID the user is apart of. user_id (str): Target User ID - + Returns: Dict: Specified users pickup group, and the users within that group. """ @@ -611,18 +536,25 @@ def call_pickup_group_user(self, service_provider_id, group_id, user_id): params = { "serviceProviderId": service_provider_id, "groupId": group_id, - "userId": user_id + "userId": user_id, } return self.requester.get(endpoint, params=params) -#CALL POLICIES -#CALL PROCESSING POLICIES -#CALL RECORDING -#CALL RECORDS - - def users_stats(self, user_id: str, start_date:str, end_date: str = None, - start_time: str = "00:00:00", end_time:str = "23:59:59", time_zone: str = "Z"): + # CALL POLICIES + # CALL PROCESSING POLICIES + # CALL RECORDING + # CALL RECORDS + + def users_stats( + self, + user_id: str, + start_date: str, + end_date: str = None, + start_time: str = "00:00:00", + end_time: str = "23:59:59", + time_zone: str = "Z", + ): """Pulls a single users call statistics for a specified period of time. Args: @@ -640,51 +572,51 @@ def users_stats(self, user_id: str, start_date:str, end_date: str = None, Returns: Dict: Users call record statistics for specified time period. """ - - #checks if end_date has been left and therefore we assume user wants same date. + + # checks if end_date has been left and therefore we assume user wants same date. if not end_date: end_date = start_date - + endpoint = "/users/call-records/stats" params = { "userIds": user_id, "startTime": f"{start_date}T{start_time}{time_zone}", - "endTime": f"{end_date}T{end_time}{time_zone}" + "endTime": f"{end_date}T{end_time}{time_zone}", } return self.requester.get(endpoint, params=params) -#CALL TRANSFER -#CALL WAITING -#CALLING LINE ID BLOCKING OVERRIDE -#CALLING LINE ID DELIVERY BLOCKING -#CALLING NAME DELIVERY -#CALLING NAME RETRIEVAL -#CALLING NUMBER DELIVERY -#CALLING PARTY CATEGORY -#CALLING PLANS -#CALLBACKS -#CHARGENUMBER -#CLASSMARK -#CLONE -#COLLABORATE -#COMM PILOT CALL MANAGER -#COMM PILOT EXPRESS -#COMMON PHONE LIST -#COMMUNICATION BARRING -#COMMUNICATION BARRING USER -#CONNECTED LINE IDENTIFICATION -#CUSTOM CONTACT DIRECTORY -#DEPARTMENTS -#DEVICE POLICIES -#DEVICES -#DIAL PLAN POLICY -#DIRECTED CALL PICKUP WITH BARGE IN -#DIRECTROUTE -#DN - - def group_dns(self, service_provider_id:str, group_id:str): + # CALL TRANSFER + # CALL WAITING + # CALLING LINE ID BLOCKING OVERRIDE + # CALLING LINE ID DELIVERY BLOCKING + # CALLING NAME DELIVERY + # CALLING NAME RETRIEVAL + # CALLING NUMBER DELIVERY + # CALLING PARTY CATEGORY + # CALLING PLANS + # CALLBACKS + # CHARGENUMBER + # CLASSMARK + # CLONE + # COLLABORATE + # COMM PILOT CALL MANAGER + # COMM PILOT EXPRESS + # COMMON PHONE LIST + # COMMUNICATION BARRING + # COMMUNICATION BARRING USER + # CONNECTED LINE IDENTIFICATION + # CUSTOM CONTACT DIRECTORY + # DEPARTMENTS + # DEVICE POLICIES + # DEVICES + # DIAL PLAN POLICY + # DIRECTED CALL PICKUP WITH BARGE IN + # DIRECTROUTE + # DN + + def group_dns(self, service_provider_id: str, group_id: str): """Gets all numbers assigned to group. Args: @@ -692,21 +624,23 @@ def group_dns(self, service_provider_id:str, group_id:str): group_id (str): Group ID of target group. Returns: - Dict: Dictionary containing all DNs assigned to group. + Dict: Dictionary containing all DNs assigned to group. """ endpoint = "/groups/dns" - params = { - "serviceProviderId": service_provider_id, - "groupId": group_id - } - + params = {"serviceProviderId": service_provider_id, "groupId": group_id} + return self.requester.get(endpoint, params=params) - - - def group_dn_search(self, service_provider_id:str, group_id:str, dn: int, - filter_type: str = None, limit: int = None): + + def group_dn_search( + self, + service_provider_id: str, + group_id: str, + dn: int, + filter_type: str = None, + limit: int = None, + ): """Searches for numbers assigned to group and allows search criteria and limiting result. Args: @@ -721,23 +655,19 @@ def group_dn_search(self, service_provider_id:str, group_id:str, dn: int, """ endpoint = "/groups/dns/search" - - params = { - "serviceProviderId": service_provider_id, - "groupId": group_id - } - + + params = {"serviceProviderId": service_provider_id, "groupId": group_id} + if filter_type: params["dn"] = format_filter_value(filter_type, dn) if limit: params["limit"] = limit - + return self.requester.get(endpoint, params=params) - - - def group_dn_details(self, service_provider_id:str, group_id:str): + + def group_dn_details(self, service_provider_id: str, group_id: str): """Gets all numbers assigned to Group in detail. This will show where the number is assigned - in a group such as which user or hunt group. + in a group such as which user or hunt group. Args: service_provider_id (str): Service Provider or Enterprise ID where group is hosted. @@ -746,17 +676,13 @@ def group_dn_details(self, service_provider_id:str, group_id:str): Returns: Dict: Dictionary of numbers with details of each number. """ - + endpoint = "/groups/dns/details" - - params = { - "serviceProviderId": service_provider_id, - "groupId": group_id - } + + params = {"serviceProviderId": service_provider_id, "groupId": group_id} return self.requester.get(endpoint, params=params) - - + def system_dn_search(self, dn: int): """Searches for number from System level. This will return where the number is located on the system. It will show the Service Provider/ Enterprise, Group ID, and User ID the number is assigned to. @@ -765,18 +691,15 @@ def system_dn_search(self, dn: int): dn (int): Target number excluding country code e.g. 123456789 Returns: - List: List of dictionaries containing details of each number that fit the search criteria. + List: List of dictionaries containing details of each number that fit the search criteria. """ - + endpoint = "/system/dns/search" - params = { - "dn": f"+{dn}" - } + params = {"dn": f"+{dn}"} return self.requester.get(endpoint, params=params) - - + def system_dn(self, dn: int): """Searches for number from System level. This will return where the number is located on the system. It will show the Service Provider/ Enterprise, Group ID, and User ID the number is assigned to. @@ -785,44 +708,44 @@ def system_dn(self, dn: int): dn (int): Target number excluding country code e.g. 123456789 Returns: - List: List of dictionaries containing details of each number that fit the search criteria. + List: List of dictionaries containing details of each number that fit the search criteria. """ - + endpoint = "/system/dns" - - params = { - "phoneNumber": f"+{dn}" - } + + params = {"phoneNumber": f"+{dn}"} return self.requester.get(endpoint, params=params) - - + def system_dn_summary(self): """Returns all numbers assigned to system. Returns: List: List of all Service Providers/ Enterprises and numbers assigned in ranges. """ - + endpoint = "/system/dns/summary" - + return self.requester.get(endpoint) - - + def system_dn_utilization(self): """Returns DN statistics for each Service Provider/ Enterprise such as total DNs assigned. Returns: List: List of all Service Provider/ Enterprises with statistics of DNs for each. """ - - endpoint = "/system/dns/utilization" - - return self.requester.get(endpoint) - - - def service_provider_dn_search(self, service_provider_id:str, dn: int, - filter_type: str = None, limit: int = None): + + endpoint = "/system/dns/utilization" + + return self.requester.get(endpoint) + + def service_provider_dn_search( + self, + service_provider_id: str, + dn: int, + filter_type: str = None, + limit: int = None, + ): """Searches for numbers assigned to Service Provider/ Enterprise and allows search criteria and limiting result. Args: @@ -836,19 +759,16 @@ def service_provider_dn_search(self, service_provider_id:str, dn: int, """ endpoint = "/service-providers/dns/search" - - params = { - "serviceProviderId": service_provider_id - } - + + params = {"serviceProviderId": service_provider_id} + if filter_type: params["dn"] = format_filter_value(filter_type, dn) if limit: params["limit"] = limit return self.requester.get(endpoint, params=params) - - + def service_provider_dns(self, service_provider_id: str): """Returns all numbers assigned to Service Provider/ Enterprise with the group its assigned to and if the numbers can be deleted. @@ -859,51 +779,46 @@ def service_provider_dns(self, service_provider_id: str): Returns: Dict: All numbers assigend to Service Provider/ Enterprise with group and delete status. """ - + endpoint = "/service-providers/dns" - - params = { - "serviceProviderId": service_provider_id - } + + params = {"serviceProviderId": service_provider_id} return self.requester.get(endpoint, params=params) - - -#DO NOT DISTURB + + # DO NOT DISTURB def user_do_not_disturb(self, user_id: str): """Returns the specificied users DND and Ring Splash state. Args: - user_id (str): Target user id to return data. + user_id (str): Target user id to return data. Returns: Dict: States DND and Ring Splash status. """ - + endpoint = "/users/do-not-disturb" - - params = { - "userId": user_id - } + + params = {"userId": user_id} return self.requester.get(endpoint, params=params) -#DOMAINS -#EMERGENCY NOTIFICATIONS -#EMERGENCY ZONES -#ENTERPRISE TRUNKS -#EXECUTIVE -#EXECUTIVE ASSISTANT -#EXTENSIONS -#EXTERNAL CALLING LINE ID DELIVERY -#EXTERNAL CUSTOM RINGBACK -#FAX MESSAGING -#FEATURE ACCESS CODES -#FLEXIBLE SEATING -#GROUP PAGING -#GROUPS - + # DOMAINS + # EMERGENCY NOTIFICATIONS + # EMERGENCY ZONES + # ENTERPRISE TRUNKS + # EXECUTIVE + # EXECUTIVE ASSISTANT + # EXTENSIONS + # EXTERNAL CALLING LINE ID DELIVERY + # EXTERNAL CUSTOM RINGBACK + # FAX MESSAGING + # FEATURE ACCESS CODES + # FLEXIBLE SEATING + # GROUP PAGING + # GROUPS + def groups(self, service_provider_id: str): """Returns the specificied Service Provider's Groups. @@ -915,14 +830,11 @@ def groups(self, service_provider_id: str): """ endpoint = "/groups" - - params = { - "serviceProviderId": service_provider_id - } + + params = {"serviceProviderId": service_provider_id} return self.requester.get(endpoint, params=params) - - + def group(self, service_provider_id, group_id): """Returns the specificied Group's settings and information. @@ -936,17 +848,14 @@ def group(self, service_provider_id, group_id): endpoint = "/groups" - params = { - "serviceProviderId": service_provider_id, - "groupId": group_id - } + params = {"serviceProviderId": service_provider_id, "groupId": group_id} return self.requester.get(endpoint, params=params) -#GROUP NAVIGATION -#HOTELING GUEST -#HOTELING HOST -#HUNT GROUPS + # GROUP NAVIGATION + # HOTELING GUEST + # HOTELING HOST + # HUNT GROUPS def group_hunt_groups(self, service_provider_id, group_id): """Returns a list of all the Hunt Groups within the specified Group. @@ -961,10 +870,7 @@ def group_hunt_groups(self, service_provider_id, group_id): endpoint = "/groups/hunt-groups" - params = { - "serviceProviderId": service_provider_id, - "groupId": group_id - } + params = {"serviceProviderId": service_provider_id, "groupId": group_id} return self.requester.get(endpoint, params=params) @@ -980,9 +886,7 @@ def group_hunt_group(self, service_user_id): endpoint = "/groups/hunt-groups" - params = { - "serviceUserId" : service_user_id - } + params = {"serviceUserId": service_user_id} return self.requester.get(endpoint, params=params) @@ -999,18 +903,19 @@ def group_hunt_group_user(self, service_provider_id, group_id, user_id): """ endpoint = "/groups/hunt-groups/user" - + params = { "serviceProviderId": service_provider_id, "groupId": group_id, - "userId": user_id + "userId": user_id, } return self.requester.get(endpoint, params=params) - - def group_hunt_groups_available_users(self, service_provider_id: str, group_id: str): - """Returns a list of all users within the service provider that are available to be assigned to a hunt group in the specified group. + def group_hunt_groups_available_users( + self, service_provider_id: str, group_id: str + ): + """Returns a list of all users within the service provider that are available to be assigned to a hunt group in the specified group. Args: service_provider_id (str): Target Service Provider ID @@ -1022,140 +927,129 @@ def group_hunt_groups_available_users(self, service_provider_id: str, group_id: endpoint = "/groups/hunt-groups/users" - params = { - "serviceProviderId": service_provider_id, - "groupId": group_id - } + params = {"serviceProviderId": service_provider_id, "groupId": group_id} return self.requester.get(endpoint, params=params) - -#IN CALL SERVICE ACTIVATION -#INSTANT GROUP CALL -#INTEGRATED IMP -#INTERCEPT -#INTERNAL CALLING LINE ID DELIVERY -#LANGUAGES -#LEGACY AUTOMATIC CALLBACK -#MALICIOUS CALL TRACE -#MEDIA -#MEET-ME CONFERENCING -#MUSIC ON HOLD -#MWI DELIVERY TO MOBILE ENDPOINT -#NETWORK CLASS OF SERVICE -#NIGHT FORWARDING -#NUMBER PORTABILITY ANNOUNCEMENT -#NUMBER PORTABILITY QUERY -#NUMBERS -#OUTLOOK INTEGRATION -#PASSCODE RULES -#PASSWORD GENERATE + # IN CALL SERVICE ACTIVATION + # INSTANT GROUP CALL + # INTEGRATED IMP + # INTERCEPT + # INTERNAL CALLING LINE ID DELIVERY + # LANGUAGES + # LEGACY AUTOMATIC CALLBACK + # MALICIOUS CALL TRACE + # MEDIA + # MEET-ME CONFERENCING + # MUSIC ON HOLD + # MWI DELIVERY TO MOBILE ENDPOINT + # NETWORK CLASS OF SERVICE + # NIGHT FORWARDING + # NUMBER PORTABILITY ANNOUNCEMENT + # NUMBER PORTABILITY QUERY + # NUMBERS + # OUTLOOK INTEGRATION + # PASSCODE RULES + # PASSWORD GENERATE def password_generate(self, service_provider_id: str, group_id: str) -> dict: """Generates a single passwords following the groups rules. Args: service_provider_id (str): Service Provider ID where Group is located. - group_id (str): Group ID to generate password for. + group_id (str): Group ID to generate password for. Returns: dict: Single password generated according to the groups rules. """ - + endpoint = "/password/generate" - - params = { - "serviceProviderId": service_provider_id, - "groupId": group_id - } + + params = {"serviceProviderId": service_provider_id, "groupId": group_id} return self.requester.get(endpoint, params=params) - - - def passwords_generate(self, service_provider_id: str, group_id: str, limit: int =10) -> dict: + + def passwords_generate( + self, service_provider_id: str, group_id: str, limit: int = 10 + ) -> dict: """Generates a multiple passwords to the limit set in pararmeters. Args: service_provider_id (str): Service Provider ID where Group is located. - group_id (str): Group ID to generate password for. + group_id (str): Group ID to generate password for. limit (int, optional): Number of passwords api will return. Defaults to 10. Returns: dict: Multiple passwords generated according to the groups rules. """ - + endpoint = "/password/generate" - + params = { "serviceProviderId": service_provider_id, "groupId": group_id, - "limit": limit + "limit": limit, } - return self.requester.get(endpoint, params = params) - - + return self.requester.get(endpoint, params=params) + def passcode_generate(self, service_provider_id: str, group_id: str) -> dict: """Generates a single passcode following group rules. Args: service_provider_id (str): Service Provider ID where Group is located. - group_id (str): Group ID to generate passcode for. + group_id (str): Group ID to generate passcode for. Returns: dict: Single passcode generated according to the groups rules. """ - + endpoint = "/passcode/generate" - - params = { - "serviceProviderId": service_provider_id, - "groupId": group_id - } - return self.requester.get(endpoint, params = params) - - - def passcodes_generate(self, service_provider_id: str, group_id: str, limit: int =10) -> dict: + params = {"serviceProviderId": service_provider_id, "groupId": group_id} + + return self.requester.get(endpoint, params=params) + + def passcodes_generate( + self, service_provider_id: str, group_id: str, limit: int = 10 + ) -> dict: """Generates a multiple passcodes to the limit set in pararmeters. Args: service_provider_id (str): Service Provider ID where Group is located. - group_id (str): Group ID to generate passcodes for. + group_id (str): Group ID to generate passcodes for. limit (int, optional): Number of passwords api will return. Defaults to 10. Returns: dict: Multiple passcodes generated according to the groups rules. """ - + endpoint = "/passcode/generate" - + params = { "serviceProviderId": service_provider_id, "groupId": group_id, - "limit": limit + "limit": limit, } - return self.requester.get(endpoint, params = params) - - + return self.requester.get(endpoint, params=params) + def sip_password_generate(self) -> dict: """Generates a single SIP password. Args: service_provider_id (str): Service Provider ID where Group is located. - group_id (str): Group ID to generate SIP password for. + group_id (str): Group ID to generate SIP password for. Returns: dict: Single SIP password generated according to the groups rules. """ - + endpoint = "/sip-password/generate" - + return self.requester.get(endpoint) - - - def sip_passwords_generate(self, limit: int =10) -> dict: + + def sip_passwords_generate(self, limit: int = 10) -> dict: """Generates multiple SIP passwords to the limit set in parameters. Defaults to 10. Args: @@ -1166,27 +1060,25 @@ def sip_passwords_generate(self, limit: int =10) -> dict: """ endpoint = "/password/generate" - - params = { - "limit": limit - } - return self.requester.get(endpoint, params = params) - -#PASSWORD RULES -#PERSONAL PHONE LIST -#PHONE DIRECTORY -#PHYSICAL LOCATION -#POLYCOM PHONE SERVICES -#PRE ALERTING -#PREFERRED CARRIER -#PREPAID -#PRIMARY ENDPOINT ADVANCED SETTING -#PRIORITY ALERT -#PRIVACY -#PUSH REGISTRATION -#PUSH TO TALK -#REGISTRATION + params = {"limit": limit} + + return self.requester.get(endpoint, params=params) + + # PASSWORD RULES + # PERSONAL PHONE LIST + # PHONE DIRECTORY + # PHYSICAL LOCATION + # POLYCOM PHONE SERVICES + # PRE ALERTING + # PREFERRED CARRIER + # PREPAID + # PRIMARY ENDPOINT ADVANCED SETTING + # PRIORITY ALERT + # PRIVACY + # PUSH REGISTRATION + # PUSH TO TALK + # REGISTRATION def user_registration(self, user_id: str): """Gets a users devices and if those devices are registered. This includes soft phones. @@ -1197,41 +1089,35 @@ def user_registration(self, user_id: str): Returns: dict: All users devices and details on device such as registration. """ - + endpoint = "/users/registration" - params = { - "userId": user_id - } + params = {"userId": user_id} return self.requester.get(endpoint, params=params) - - + def bulk_user_registration(self, service_provider_id: str, group_id: str): """Gets all users in a group and their device registrations. This includes soft phones. Args: - service_provider_id (str): Service Provider/ Enterprise ID where Group is hosted. - group_id (str): Target Group ID where users are located. + service_provider_id (str): Service Provider/ Enterprise ID where Group is hosted. + group_id (str): Target Group ID where users are located. Returns: dict: All users devices and details on device such as registration. """ - + endpoint = "/users/registration/bulk" - params = { - "serviceProviderId": service_provider_id, - "groupId": group_id - } + params = {"serviceProviderId": service_provider_id, "groupId": group_id} return self.requester.get(endpoint, params=params) -#REMOTE OFFICE -#REPORTS + # REMOTE OFFICE + # REPORTS def user_report(self, user_id: str): - """ Detailed report of user including services and service packs assigned. + """Detailed report of user including services and service packs assigned. Args: user_id (str): Target user id of user. @@ -1242,19 +1128,17 @@ def user_report(self, user_id: str): endpoint = "/users/reports/users" - params = { - "userId": user_id - } + params = {"userId": user_id} return self.requester.get(endpoint, params=params) -#RESELLERS -#ROUTE LIST -#ROUTING PROFILE -#SCHEDULES + # RESELLERS + # ROUTE LIST + # ROUTING PROFILE + # SCHEDULES def group_schedules(self, service_provider_id: str, group_id: str): - """ Retrieves the Business Schedules for the specified group. + """Retrieves the Business Schedules for the specified group. Args: service_provider_id (str): Target Service Provider ID where group is hosted. @@ -1263,19 +1147,17 @@ def group_schedules(self, service_provider_id: str, group_id: str): Returns: List: List of all the groups schedules, including Name, Type and Level. """ - + endpoint = "/groups/schedules" - - params = { - "serviceProviderId": service_provider_id, - "groupId": group_id - } + + params = {"serviceProviderId": service_provider_id, "groupId": group_id} return self.requester.get(endpoint, params=params) - - - def group_events(self, service_provider_id: str, group_id: str, name: str, type: str): - """ Retrieves the Business Schedule's Events for the specified group. + + def group_events( + self, service_provider_id: str, group_id: str, name: str, type: str + ): + """Retrieves the Business Schedule's Events for the specified group. Args: service_provider_id (str): Target Service Provider ID @@ -1286,26 +1168,25 @@ def group_events(self, service_provider_id: str, group_id: str, name: str, type: Returns: List: List of each Business Schedule Event, including startTime and endTime. """ - + endpoint = "/groups/events" - + params = { "serviceProviderId": service_provider_id, "groupId": group_id, "name": name, - "type": type + "type": type, } - return self.requester.get(endpoint, params=params) - - -#SECURITY CLASSIFICATION -#SELECTIVE CALL ACCEPTANCE -#SELECTIVE CALL REJECTION -#SEQUENTIAL RING -#SERIES COMPLETION -#SERVICE PACKS -#SERVICE PROVIDERS + return self.requester.get(endpoint, params=params) + + # SECURITY CLASSIFICATION + # SELECTIVE CALL ACCEPTANCE + # SELECTIVE CALL REJECTION + # SEQUENTIAL RING + # SERIES COMPLETION + # SERVICE PACKS + # SERVICE PROVIDERS def service_providers(self, reseller_id=None): """ @@ -1313,28 +1194,23 @@ def service_providers(self, reseller_id=None): reseller_id (str): Only list the Service Provider IDs within the specified Reseller. """ endpoint = "/service-providers" - params = { - "resellerId": reseller_id - } - - return self.requester.get(endpoint, params=params) + params = {"resellerId": reseller_id} + return self.requester.get(endpoint, params=params) def service_provider(self, service_provider_id: str): """ Args: reseller_id (str): Only list the Service Provider IDs within the specified Reseller. """ - + endpoint = "/service-providers" - - params = { - "serviceProviderId": service_provider_id - } + + params = {"serviceProviderId": service_provider_id} return self.requester.get(endpoint, params=params) -#SERVICES + # SERVICES def user_services_assigned(self, user_id: str): """ @@ -1343,15 +1219,13 @@ def user_services_assigned(self, user_id: str): user_id (str): _description_ """ endpoint = "/users/services/assigned" - - params = { - "userId": user_id - } + + params = {"userId": user_id} return self.requester.get(endpoint, params=params) def user_services(self, user_id: str): - """Fetch all services assigned to a broadwrok entity, this can be + """Fetch all services assigned to a broadwrok entity, this can be a user, AA, CC, or HG. Args: @@ -1363,9 +1237,7 @@ def user_services(self, user_id: str): endpoint = "/users/services" - params = { - "userId": user_id - } + params = {"userId": user_id} return self.requester.get(endpoint, params=params) @@ -1381,18 +1253,16 @@ def user_service_settings(self, user_id: str): endpoint = f"/users/services/settings" - params = { - "userId": user_id - } - + params = {"userId": user_id} + return self.requester.get(endpoint, params=params) - + def group_services(self, group_id: str, service_provider_id: str): """ Fetch all userServices, groupServices and servicePackServices assigned to a group. Args: - group_id (str): GroupID of the target + group_id (str): GroupID of the target service_provider_id (str): Service Provider or Enterprise ID of the target. Returns: @@ -1401,14 +1271,17 @@ def group_services(self, group_id: str, service_provider_id: str): endpoint = "/groups/services" - params = { - "groupId": group_id, - "serviceProviderId": service_provider_id - } + params = {"groupId": group_id, "serviceProviderId": service_provider_id} return self.requester.get(endpoint, params=params) - def group_services_user_assigned(self, group_id: str, service_provider_id: str, service_name: str, service_type: str): + def group_services_user_assigned( + self, + group_id: str, + service_provider_id: str, + service_name: str, + service_type: str, + ): """ Get details of the user/service instances where a particular service is assigned. @@ -1428,27 +1301,27 @@ def group_services_user_assigned(self, group_id: str, service_provider_id: str, "groupId": group_id, "serviceProviderId": service_provider_id, "serviceType": service_type, - "serviceName": service_name + "serviceName": service_name, } return self.requester.get(endpoint, params=params) -#SHARED CALL APPEARANCE -#SILENT ALERTING -#SIMULTANEOUS RING PERSONAL -#SMARTY ADDRESS -#SPEED DIAL 100 -#SPEED DIAL 8 -#STATES AND PROVINCES -#SYSTEM -#TERMINATING ALTERNATE TRUNK IDENTITY -#THIRD PARTY VOICE MAIL SUPPORT -#THIRD PARTY EMERGENCY CALLING -#TIME ZONES -#TRUNK GROUPS - + # SHARED CALL APPEARANCE + # SILENT ALERTING + # SIMULTANEOUS RING PERSONAL + # SMARTY ADDRESS + # SPEED DIAL 100 + # SPEED DIAL 8 + # STATES AND PROVINCES + # SYSTEM + # TERMINATING ALTERNATE TRUNK IDENTITY + # THIRD PARTY VOICE MAIL SUPPORT + # THIRD PARTY EMERGENCY CALLING + # TIME ZONES + # TRUNK GROUPS + def group_trunk_groups_call_capacity(self, service_provider_id: str, group_id: str): - """Fetches Trunk Call Capacity data for a single Group. + """Fetches Trunk Call Capacity data for a single Group. Args: service_provider_id (str): Service Provider/ Enterprise ID where Group is located. @@ -1457,18 +1330,16 @@ def group_trunk_groups_call_capacity(self, service_provider_id: str, group_id: s Returns: Dict: Trunk Group Call Capacity data of target group. """ - + endpoint = "/groups/trunk-groups/call-capacity" - - params = { - "groupId": group_id, - "serviceProviderId": service_provider_id - } + + params = {"groupId": group_id, "serviceProviderId": service_provider_id} return self.requester.get(endpoint, params=params) - - - def group_trunk_group(self, service_provider_id: str, group_id: str, trunk_group_name: str): + + def group_trunk_group( + self, service_provider_id: str, group_id: str, trunk_group_name: str + ): """Fetches all Trunk Group details of a single Trunk Group in a Group. Args: @@ -1479,18 +1350,17 @@ def group_trunk_group(self, service_provider_id: str, group_id: str, trunk_group Returns: Dict: Details of a target trunk group. """ - + endpoint = "/groups/trunk-groups" - + params = { "groupId": group_id, "serviceProviderId": service_provider_id, - "name": trunk_group_name + "name": trunk_group_name, } return self.requester.get(endpoint, params=params) - - + def group_trunk_groups(self, service_provider_id: str, group_id: str): """Fetches list of all trunk groups in a single group. @@ -1501,17 +1371,13 @@ def group_trunk_groups(self, service_provider_id: str, group_id: str): Returns: List: List of core details of all Trunk Groups located in a single Group. """ - + endpoint = "/groups/trunk-groups" - - params = { - "groupId": group_id, - "serviceProviderId": service_provider_id - } + + params = {"groupId": group_id, "serviceProviderId": service_provider_id} return self.requester.get(endpoint, params=params) - - + def service_provider_trunk_group_call_capacity(self, service_provider_id: str): """Fetches trunk call capacity details of a single Service Provider. @@ -1521,16 +1387,13 @@ def service_provider_trunk_group_call_capacity(self, service_provider_id: str): Returns: Dict: Trunk call capacity details of a single Service Provider/ Enterprise ID. """ - + endpoint = "/service-providers/trunk-groups/call-capacity" - - params = { - "serviceProviderId": service_provider_id - } + + params = {"serviceProviderId": service_provider_id} return self.requester.get(endpoint, params=params) - - + def service_provider_trunk_call_capacity_report(self, service_provider_id: str): """Fetches trunk call capacity details of Service Provider/ Enterprise and all Groups in the SP/ ENT. @@ -1541,22 +1404,26 @@ def service_provider_trunk_call_capacity_report(self, service_provider_id: str): Dict: Breakdown of all trunk call capacity details of target Service Provider/ Enterprise and all Groups \ in the target SP/ ENT. """ - + endpoint = "/service-providers/trunk-groups/call-capacity/reports" - - params = { - "serviceProviderId": service_provider_id - } + + params = {"serviceProviderId": service_provider_id} return self.requester.get(endpoint, params=params) - -#TWO STAGE DIALING -#USERS + # TWO STAGE DIALING + # USERS - def users(self, service_provider_id: str = None, group_id: str = None, - filter: str = None, filter_type: str = None, filter_value: str = None, - limit: int = None, extended=False): + def users( + self, + service_provider_id: str = None, + group_id: str = None, + filter: str = None, + filter_type: str = None, + filter_value: str = None, + limit: int = None, + extended=False, + ): """ Returns list of users depending on filter criteria. @@ -1596,7 +1463,7 @@ def users(self, service_provider_id: str = None, group_id: str = None, """ endpoint = "/users?" - + params = {} if service_provider_id: @@ -1614,23 +1481,22 @@ def users(self, service_provider_id: str = None, group_id: str = None, def user_by_id(self, user_id: str): """Returns extensive details of a single user including alias, enpoint device, and more common - details like first and last name. + details like first and last name. Args: user_id (str): Target user ID of the user you would like to review. Returns: - Dict: Python dictionary of the users details + Dict: Python dictionary of the users details """ endpoint = "/users" - params = { - "userId": user_id - } + params = {"userId": user_id} return self.requester.get(endpoint, params=params) + # USER CUSTOM RINGBACK # VIDEO ADD ON # VIRTUAL ON-NET ENTERPRISE EXTENSIONS diff --git a/odins_spear/reporter.py b/odins_spear/reporter.py index 9afd31d..b3d6f64 100644 --- a/odins_spear/reporter.py +++ b/odins_spear/reporter.py @@ -1,15 +1,20 @@ from . import reports + class Reporter: - """ generates human friendly reports. - """ - + """generates human friendly reports.""" + def __init__(self, api) -> None: self.api = api - - - def call_flow(self, service_provider_id: str, group_id: str, number: str, number_type: str, - broadworks_entity_type: str): + + def call_flow( + self, + service_provider_id: str, + group_id: str, + number: str, + number_type: str, + broadworks_entity_type: str, + ): """Generates a graphical flow chart of how a call to a specified number routes through the broadworks system. @@ -21,14 +26,26 @@ def call_flow(self, service_provider_id: str, group_id: str, number: str, number broadworks_entity_type (str): Broadworks entity type target number is associated with. \ Options: "auto_attendant": Auto Attendant, "call_center": Call Center, "hunt_group": Hunt Group, "user": User """ - - return reports.call_flow.main(self.api, service_provider_id, group_id, number, number_type, - broadworks_entity_type) - - def group_users_call_statistics(self, service_provider_id: str, group_id: str, - start_date:str, end_date: str = None, - start_time: str = "00:00:00", end_time:str = "23:59:59", - time_zone: str = "Z"): + + return reports.call_flow.main( + self.api, + service_provider_id, + group_id, + number, + number_type, + broadworks_entity_type, + ) + + def group_users_call_statistics( + self, + service_provider_id: str, + group_id: str, + start_date: str, + end_date: str = None, + start_time: str = "00:00:00", + end_time: str = "23:59:59", + time_zone: str = "Z", + ): """Generates a CSV deatiling each users incoming and outgoing call statistics over a specified period for a single group. Each row contains user extension, user ID, and call stats. @@ -45,7 +62,27 @@ def group_users_call_statistics(self, service_provider_id: str, group_id: str, time_zone (str, optional): A specified time you would like to see call records in. \ Time zone must follow format 'GMT', 'EST', 'PST'. Defaults to "Z" (UTC Time Zone). """ - return reports.group_users_call_statistics.main(self.api, service_provider_id, group_id, - start_date, end_date, start_time, end_time, time_zone) - - \ No newline at end of file + return reports.group_users_call_statistics.main( + self.api, + service_provider_id, + group_id, + start_date, + end_date, + start_time, + end_time, + time_zone, + ) + + def user_registration_report(self, service_provider_id: str, group_id: str): + """Generates an Excel Worksheet detailing each Users ID, device name and registration status within a group. + + Args: + service_provider_id (str): Service Provider/ Enterprise where group is hosted. + group_id (str): Target Group you would like to check the registration of. + + Returns: + Xlsx File into .os_reports/ named "Registration_report_for_(GroupID)" + """ + return reports.user_registration_report.main( + self.api, service_provider_id, group_id + ) diff --git a/odins_spear/reports/__init__.py b/odins_spear/reports/__init__.py index d392d68..a1a78ba 100644 --- a/odins_spear/reports/__init__.py +++ b/odins_spear/reports/__init__.py @@ -5,3 +5,4 @@ from .call_flow import main from .group_users_call_statistics import main +from .user_registration_report import main diff --git a/odins_spear/reports/user_registration_report.py b/odins_spear/reports/user_registration_report.py new file mode 100644 index 0000000..5e015ec --- /dev/null +++ b/odins_spear/reports/user_registration_report.py @@ -0,0 +1,40 @@ +import pandas as pd + + +def export_to_xlsx(data: dict, group_id: str): + rows = [] + print("Start.\n") + print("Generating report.\n") + + for user_id, user_data in data.items(): + registration = user_data.get("registration", {}) + + if not registration: + rows.append([user_id, None, False]) + else: + for device_name, registration_info in registration.items(): + rows.append( + [user_id, device_name, registration_info.get("registered", False)] + ) + + dataframe = pd.DataFrame(rows, columns=["User ID", "Device Name", "Registered"]) + dataframe.to_excel( + f"./os_reports/Registration_report_for_{group_id}.xlsx", + index=False, + ) + print("End.\n") + + +def main(api, service_provider_id: str, group_id: str): + """Generates an Excel Worksheet detailing each Users ID, device name and registration status within a group. + + Args: + service_provider_id (str): Service Provider/ Enterprise where group is hosted. + group_id (str): Target Group you would like to check the registration of. + + Returns: + Xlsx File into .os_reports/ named "Registration_report_for_(GroupID)" + """ + data = api.scripter.user_registration(service_provider_id, group_id) + + export_to_xlsx(data, group_id) diff --git a/odins_spear/scripter.py b/odins_spear/scripter.py index d2eec25..446196e 100644 --- a/odins_spear/scripter.py +++ b/odins_spear/scripter.py @@ -2,11 +2,11 @@ class Scripter: - """ This object acts as the gateway to all pre-written scripts in /scripts/. - + """This object acts as the gateway to all pre-written scripts in /scripts/. + - Each api object created creates its own associated Scripter object on api creation. - Additionally, this object can be created solely and passed an api, however, this + Each api object created creates its own associated Scripter object on api creation. + Additionally, this object can be created solely and passed an api, however, this will result in two exact Scripter objects. Intended use: odin_api.scripter.{script function} @@ -19,46 +19,48 @@ def __init__(self, api) -> None: def aa_cc_hg_audit(self, service_provider_id: str, group_id: str): """ - This script returns the services assigned to Auto Attendants, - Call Centres, and Hunt Groups. Only services are applied to these - entities and there are scenarios one would need to focus services + This script returns the services assigned to Auto Attendants, + Call Centres, and Hunt Groups. Only services are applied to these + entities and there are scenarios one would need to focus services assigned to these entities. - + Args: service_provider_id: Service Provider ID or Enterprise ID containing the Group ID. group_id: Group ID to generate the report for. Returns: - JSON: A JSON formatted report of service packs assigned to AA, CC, and HG. - """ + JSON: A JSON formatted report of service packs assigned to AA, CC, and HG. + """ 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): return scripts.bulk_enable_voicemail.main(self.api, users) - - def bulk_password_reset(self, service_provider_id: str, group_id: str, users: list, password_type: str): - """ Resets a list of users SIP passwords or Voicemail passcodes. Specify in password_type with the options of - 'SIP' or 'Voicemail' and the script will perform the necessary actions. + def bulk_password_reset( + self, service_provider_id: str, group_id: str, users: list, password_type: str + ): + """Resets a list of users SIP passwords or Voicemail passcodes. Specify in password_type with the options of + 'SIP' or 'Voicemail' and the script will perform the necessary actions. Args: service_provider_id (str): Service Provider ID where group is hosted. group_id (str): Group ID where target users are located. users (list): List of User IDs of the target users to reset the password. - password_type (str): Type of password to reset either 'SIP' or 'Voicemail'. Only accepts these two options. + password_type (str): Type of password to reset either 'SIP' or 'Voicemail'. Only accepts these two options. Raises: - OSInvalidPasswordType: Only valid password options are SIP, VM, WEB. If another is requested this will be raised. - + OSInvalidPasswordType: Only valid password options are SIP, VM, WEB. If another is requested this will be raised. + Returns: Dict: Users and their new passwords. """ - return scripts.bulk_password_reset.main(self.api, service_provider_id, group_id, users, password_type) - + return scripts.bulk_password_reset.main( + self.api, service_provider_id, group_id, users, password_type + ) def find_alias(self, service_provider_id: str, group_id: str, alias: str): - """ Locates alias if assigned to broadworks entity. + """Locates alias if assigned to broadworks entity. Args: service_provider_id (str): Service Prodiver where group is hosted. @@ -67,14 +69,12 @@ def find_alias(self, service_provider_id: str, group_id: str, alias: str): Raises: AOALiasNotFound: If alias not found AOAliasNotFound error raised - + Returns: - str: Returns type and name/ userId of entity where alias located. - - """ - return scripts.find_alias.main(self.api, service_provider_id, group_id, - alias) + str: Returns type and name/ userId of entity where alias located. + """ + return scripts.find_alias.main(self.api, service_provider_id, group_id, alias) def group_audit(self, service_provider_id: str, group_id: str): """ @@ -90,11 +90,10 @@ def group_audit(self, service_provider_id: str, group_id: str): """ return scripts.group_audit.main(self.api, service_provider_id, group_id) - def service_pack_audit(self, servive_provider_id, group_id): """ A stripped down version of group audit focussing only on the service packs assigned within - the group. This only shows the service packs assigned and total count of unlike group audit + the group. This only shows the service packs assigned and total count of unlike group audit which details the users this is assigned to. Args: @@ -106,14 +105,12 @@ def service_pack_audit(self, servive_provider_id, group_id): """ return scripts.service_pack_audit.main(self.api, servive_provider_id, group_id) - def user_activity(self, user): return scripts.user_activity.main(self.api, user) - def user_association(self, service_provider_id: str, group_id: str, user_id: str): - """ - Identify a user's associations with Call Centers (CC), Hunt Groups (HG), + """ + Identify a user's associations with Call Centers (CC), Hunt Groups (HG), and Pick Up Groups. Args: @@ -124,14 +121,22 @@ def user_association(self, service_provider_id: str, group_id: str, user_id: str Returns: str: Formatted output of the user showing all CC, HG, and Pick Up user is assigned to. """ - return scripts.user_association.main(self.api, service_provider_id, group_id, user_id) - - - def move_numbers(self, current_service_provider_id: str, current_group_id: str, target_service_provider_id: str, - target_group_id: str, start_of_range_number: str, end_of_range_number: str = None) -> bool: - """Moves a list of numbers from existing group to another group on the same broadworks instance. + return scripts.user_association.main( + self.api, service_provider_id, group_id, user_id + ) + + def move_numbers( + self, + current_service_provider_id: str, + current_group_id: str, + target_service_provider_id: str, + target_group_id: str, + start_of_range_number: str, + end_of_range_number: str = None, + ) -> bool: + """Moves a list of numbers from existing group to another group on the same broadworks instance. This can move numbers between Service Provider/ Enterprise and groups in the same Service Provider/ Enterprise. - + Note: Numbers need to be strings and follow this format: +{country code}-{number}. Args: @@ -139,34 +144,49 @@ def move_numbers(self, current_service_provider_id: str, current_group_id: str, current_group_id (str): Current Group ID where numbers are located. target_service_provider_id (str): Target Service Provider/ Enterprise to move the numbers to. target_group_id (str): Target Group to move numbers to. - start_of_number_range (str): Starting number in range of numbers you would like to move. + start_of_number_range (str): Starting number in range of numbers you would like to move. end_of_number_range (str): Ending nummber in range of numbers you would like to move. If you need to move only one number do not enter a value for this paramter. Defaults to None. - + Returns: Bool: Returns a True once complete. """ - return scripts.move_numbers.main(self.api, current_service_provider_id, current_group_id, - target_service_provider_id, target_group_id, start_of_range_number, - end_of_range_number ) - - - def remove_numbers(self, service_provider_id: str, group_id: str, start_of_range_number: str, - end_of_range_number: str = None): + return scripts.move_numbers.main( + self.api, + current_service_provider_id, + current_group_id, + target_service_provider_id, + target_group_id, + start_of_range_number, + end_of_range_number, + ) + + def remove_numbers( + self, + service_provider_id: str, + group_id: str, + start_of_range_number: str, + end_of_range_number: str = None, + ): """Removes a singular or range of numbers from the entire Broadworks instance. Note: Numbers need to be strings and follow this format: +{country code}-{number}. - + Args: service_provider_id (str): Service Provider/ Enterprise ID where Group is located which hosts target numbers. group_id (str): Group ID where target numbers are located. - start_of_number_range (str): Starting number in range of numbers you would like to remove. + start_of_number_range (str): Starting number in range of numbers you would like to remove. end_of_number_range (str): Ending nummber in range of numbers you would like to remove. If you need to remove only one number do not enter a value for this paramter. Defaults to None. """ - return scripts.remove_numbers.main(self.api, service_provider_id, group_id, start_of_range_number, - end_of_range_number) + return scripts.remove_numbers.main( + self.api, + service_provider_id, + group_id, + start_of_range_number, + end_of_range_number, + def locate_free_extension( self, service_provider_id: str, group_id: str, range_start: int, range_end: int ): """Locates the lowest value free extension given the provided range of extension numbers. @@ -183,6 +203,7 @@ def locate_free_extension( self, service_provider_id: str, group_id: str, range_ """ return scripts.locate_free_extension.main( self.api, service_provider_id, group_id, range_start, range_end ) + def service_provider_trunking_capacity(self, service_provider_id: str): """Returns a JSON breakdown of the Trunking Call Capacity of a Service Provider/ Enterprise (SP/ENT). This will show the totals at each level from SP/ ENT to Group to Trunk Groups located in Groups. @@ -199,32 +220,62 @@ def service_provider_trunking_capacity(self, service_provider_id: str): Returns: JSON: JSON data of Trunking Call Capacity details of SP/ ENT, Groups, and Trunk Groups. """ - return scripts.service_provider_trunking_capacity.main(self.api, service_provider_id) - - - def webex_builder(self, service_provider_id: str, group_id: str, user_id: str, - device_type: str, email:str, primary_device: bool =True, - webex_feature_pack_name: str =None, enable_integrated_imp: bool =True): - """Builds a Webex device and assigns to user either as the primary device or a + return scripts.service_provider_trunking_capacity.main( + self.api, service_provider_id + ) + + def webex_builder( + self, + service_provider_id: str, + group_id: str, + user_id: str, + device_type: str, + email: str, + primary_device: bool = True, + webex_feature_pack_name: str = None, + enable_integrated_imp: bool = True, + ): + """Builds a Webex device and assigns to user either as the primary device or a Shared Call Appearance. Args: service_provider_id (str): Service Provider ID where group is hosted. - group_id (str): Group ID where target user is hosted. + group_id (str): Group ID where target user is hosted. user_id (str): Target user to build and add webex device. - device_type (str): Name of the device profile to apply. + device_type (str): Name of the device profile to apply. email (str): Email of user. This will be used to sign into the webex client. - primary_device (bool, optional): Setting to False will assign as SCA, True is primary. Defaults to True. + primary_device (bool, optional): Setting to False will assign as SCA, True is primary. Defaults to True. webex_feature_pack_name (str, optional): Feature pack to assign for Webex services. Defaults to None. enable_integrated_imp (bool, optional): Enables Integrated IMP service for the user if True .Defaults to True. Returns: - dict: Webex user/ device details. Includes webex client username and password, and if primary device - device type set. - + dict: Webex user/ device details. Includes webex client username and password, and if primary device + device type set. + Raises: OSLicenseNonExistent: Raised if user does not have correct license which allows for SCA devices. """ - - return scripts.webex_builder.main(self.api, service_provider_id, group_id, user_id, device_type, - email, primary_device, webex_feature_pack_name, enable_integrated_imp) \ No newline at end of file + + return scripts.webex_builder.main( + self.api, + service_provider_id, + group_id, + user_id, + device_type, + email, + primary_device, + webex_feature_pack_name, + enable_integrated_imp, + ) + + def user_registration(self, service_provider_id: str, group_id: str): + """Generates a dictionary detailing each Users ID, device name and registration status within a group. + + Args: + service_provider_id (str): Service Provider/ Enterprise where group is hosted. + group_id (str): Target Group you would like to know user statistics for. + + Returns: + dict: User's ID, Device Name, and Registration status. + """ + return scripts.user_registration.main(self.api, service_provider_id, group_id) diff --git a/odins_spear/scripts/__init__.py b/odins_spear/scripts/__init__.py index f342d8b..f7000cc 100644 --- a/odins_spear/scripts/__init__.py +++ b/odins_spear/scripts/__init__.py @@ -24,5 +24,6 @@ from .service_provider_trunking_capacity import main from .user_activity import main from .user_association import main +from .user_registration import main from .webex_builder import main from .locate_free_extension import main diff --git a/odins_spear/scripts/user_registration.py b/odins_spear/scripts/user_registration.py new file mode 100644 index 0000000..c16e220 --- /dev/null +++ b/odins_spear/scripts/user_registration.py @@ -0,0 +1,23 @@ +def main(api, service_provider_id: str, group_id: str): + + # Dictionary Descripting Total Users Devices + registrations_out = {} + + group_registration = api.get.bulk_user_registration(service_provider_id, group_id) + + users = group_registration.get("users", []) + + for user in users: + + user_id = user["profile"]["userId"] + registrations_out[user_id] = {"registration": {}} # Initialise the dictionary + + for registration in user["data"]["registrations"]: + + device_name = registration["deviceName"] + + registrations_out[user_id]["registration"][device_name] = { + "registered": True + } # All devices listed under the "registrations" attribute must be registered, so always True. + + return registrations_out