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

Secret token for login and certificate verification #7

Merged
merged 8 commits into from
Sep 3, 2024
Merged

Secret token for login and certificate verification #7

merged 8 commits into from
Sep 3, 2024

Conversation

iwatkot
Copy link
Owner

@iwatkot iwatkot commented Aug 28, 2024

Continuing work on PR: #6
@snoups

snoups and others added 3 commits August 15, 2024 19:46
@iwatkot iwatkot self-assigned this Aug 28, 2024
@iwatkot iwatkot added the invalid This doesn't seem right label Aug 28, 2024
@iwatkot iwatkot added the help wanted Extra attention is needed label Aug 28, 2024
@@ -17,6 +17,9 @@ class AsyncApi:
host (str): The XUI host URL.
username (str): The XUI username.
password (str): The XUI password.
token (str | None): The XUI secret token.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as for Api, more details about parameters and their usage.

@@ -75,14 +93,22 @@ def session(self, value: str) -> None:
self.database.session = value

@classmethod
def from_env(cls, logger: Any | None = None) -> AsyncApi:
def from_env(
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we store those parameters in envvars?
It would be nice if we still have an option to create an instance for API object without any additional arguments.
By, the way, since those two are optional (in some cases) we can also have both options: pass as arguments OR read from env. So if they're not passed let's try to find them in envvars.
Same for sync Api.

postprocess_fn: Callable[[str], Any],
) -> Any:
keys: list[str], postprocess_fn: Callable[[str], Any], required: bool = True
) -> Optional[Any]:
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any | None recommended

) # type: ignore[return-value]


def xui_token() -> str | None:
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add the required argument to all env functions?
E.g. user specifically wants to raise an error when the parameters are not found? And for required parameters set default to True, for optional to False.
Maybe we should rename the required argument to something more specific? E.g. raise_if_not_found?

@iwatkot iwatkot added enhancement New feature or request and removed help wanted Extra attention is needed invalid This doesn't seem right labels Sep 1, 2024
@iwatkot iwatkot merged commit 31fdc4f into main Sep 3, 2024
2 checks passed
@iwatkot iwatkot deleted the tls branch September 3, 2024 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants