Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cookies on successful login and add session/isactive api #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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