Modernize API Security python library
Problem
The design of the python library for API Security (a wrapper around rest api calls), has several downsides:
- Instead of raising exceptions the library forcefully exists the running program with
sys.exit(-1). - The library was implemented as a series of methods not associated with a class. This leads to the use of global variables to manage state.
- Library cannot be used with dependency injection due to design
Proposal
-
Refactor library to use a class with class methods. -
Move state management into the class itself. -
Use defined exception classes instead of forcefully exiting the process. -
Instead of directly configuring logging, instead just register a new logger and rely on the caller to initialize the logging library. -
Review log messages and look for places they can be improved or left to the caller. For example, on error raise an exception instead of logging detailed information. -
Update unit tests -
Update consumers of python library to use new design -
Release new container