Skip to content

Conversation

@amardeep-kahali-ts
Copy link

No description provided.

@amardeep-kahali-ts
Copy link
Author

amardeep-kahali-ts commented Oct 13, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant