Reason for adding these endpoints: In the perf framework, we decorate each function with a login_if_needed decorator so that we do not explicitly need to call the login APIs. Here's the code for the decorator:
def login_if_needed(func):
"""
Decorator to check if login is needed
Args:
func(object): Function which requires login
"""
def wrapper(self, *args, **kwargs):
if not self.session_isactive():
self.session_login(self.username, self.password)
return func(self, *args, **kwargs)
return wrapper
# Usage
@login_if_needed
def user_list(self) -> Dict:
endpoint = "user/list"
url = self.base_url + endpoint
response = self.requests_session.get(url=url)
response.raise_for_status()
return response.json()
It would help us if this functionality was incorporated in the library.
Reason for adding these endpoints: In the perf framework, we decorate each function with a
login_if_needed
decorator so that we do not explicitly need to call the login APIs. Here's the code for the decorator:It would help us if this functionality was incorporated in the library.