Skip to content
Snippets Groups Projects
Verified Commit b4fccc88 authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

update docstrings

parent 6d943253
No related branches found
No related tags found
1 merge request!161Feature/add mailer service
Pipeline #85726 passed
...@@ -9,6 +9,7 @@ repos: ...@@ -9,6 +9,7 @@ repos:
- --fix - --fix
- --preview - --preview
- --ignore=PLR0917,PLR0914 - --ignore=PLR0917,PLR0914
- --extend-exclude=test/*
# Run the formatter. # Run the formatter.
- id: ruff-format - id: ruff-format
args: args:
......
...@@ -58,6 +58,9 @@ Glossary of terms ...@@ -58,6 +58,9 @@ Glossary of terms
Simple Network Management Protocol: a protocol that's used for gathering data, widely used for network management Simple Network Management Protocol: a protocol that's used for gathering data, widely used for network management
and monitoring. and monitoring.
TWAMP
Two-way Active Measurement Protocol.
UUID UUID
Universally Unique Identifier Universally Unique Identifier
......
...@@ -14,4 +14,6 @@ Dark_fiber ...@@ -14,4 +14,6 @@ Dark_fiber
PHASE 1 PHASE 1
[Mm]odify [Mm]odify
AAI AAI
[M|m]iddleware [M|m]iddleware
\ No newline at end of file TWAMP
Pydantic
...@@ -82,13 +82,8 @@ class OIDCUserModel(dict): ...@@ -82,13 +82,8 @@ class OIDCUserModel(dict):
if the attribute is one of the registered claims or raises an AttributeError if the attribute is one of the registered claims or raises an AttributeError
if the key is not found. if the key is not found.
Args: :param str key: The attribute name to retrieve.
---- :return: The value of the attribute if it exists, otherwise raises AttributeError.
key: The attribute name to retrieve.
Returns:
-------
The value of the attribute if it exists, otherwise raises AttributeError.
""" """
try: try:
return object.__getattribute__(self, key) return object.__getattribute__(self, key)
...@@ -167,6 +162,7 @@ class OPAResult(BaseModel): ...@@ -167,6 +162,7 @@ class OPAResult(BaseModel):
---------- ----------
- result (bool): Indicates whether the access request is allowed or denied. - result (bool): Indicates whether the access request is allowed or denied.
- decision_id (str): A unique identifier for the decision made by OPA. - decision_id (str): A unique identifier for the decision made by OPA.
""" """
result: bool = False result: bool = False
...@@ -208,15 +204,10 @@ class OIDCUser(HTTPBearer): ...@@ -208,15 +204,10 @@ class OIDCUser(HTTPBearer):
This is used as a security module in Fastapi projects This is used as a security module in Fastapi projects
Args:
----
request: Starlette request method.
token: Optional value to directly pass a token.
Returns:
-------
OIDCUserModel object.
:param Request request: Starlette request method.
:param str token: Optional value to directly pass a token.
:return: OIDCUserModel object.
""" """
if not oauth2lib_settings.OAUTH2_ACTIVE: if not oauth2lib_settings.OAUTH2_ACTIVE:
return None return None
...@@ -380,16 +371,12 @@ def opa_decision( ...@@ -380,16 +371,12 @@ def opa_decision(
to authorize requests based on OPA policies. It utilizes OIDC for user information and makes a to authorize requests based on OPA policies. It utilizes OIDC for user information and makes a
call to the OPA service to determine authorization. call to the OPA service to determine authorization.
Args: :param str opa_url: URL of the Open Policy Agent service.
---- :param OIDCUser oidc_security: An instance of OIDCUser for user authentication.
opa_url: URL of the Open Policy Agent service. :param bool auto_error: If True, automatically raises an HTTPException on authorization failure.
oidc_security: An instance of OIDCUser for user authentication. :param Mapping[str, str] | None opa_kwargs: Additional keyword arguments to be passed to the OPA input.
auto_error: If True, automatically raises an HTTPException on authorization failure.
opa_kwargs: Additional keyword arguments to be passed to the OPA input.
Returns: :return: An asynchronous decision function that can be used as a dependency in FastAPI endpoints.
-------
An asynchronous decision function that can be used as a dependency in FastAPI endpoints.
""" """
async def _opa_decision( async def _opa_decision(
...@@ -407,6 +394,7 @@ def opa_decision( ...@@ -407,6 +394,7 @@ def opa_decision(
request: Request object that will be used to retrieve request metadata. request: Request object that will be used to retrieve request metadata.
user_info: The OIDCUserModel object that will be checked user_info: The OIDCUserModel object that will be checked
async_request: The :term:`httpx` client. async_request: The :term:`httpx` client.
""" """
if not (oauth2lib_settings.OAUTH2_ACTIVE and oauth2lib_settings.OAUTH2_AUTHORIZATION_ACTIVE): if not (oauth2lib_settings.OAUTH2_ACTIVE and oauth2lib_settings.OAUTH2_AUTHORIZATION_ACTIVE):
return None return None
......
...@@ -34,8 +34,6 @@ def get_oidc_user() -> OIDCUser: ...@@ -34,8 +34,6 @@ def get_oidc_user() -> OIDCUser:
This function returns the instance of OIDCUser initialized in the module. This function returns the instance of OIDCUser initialized in the module.
It is typically used for accessing the OIDCUser across different parts of the application. It is typically used for accessing the OIDCUser across different parts of the application.
Returns :return OIDCUser: The instance of OIDCUser configured with OAuth2 settings.
-------
OIDCUser: The instance of OIDCUser configured with OAuth2 settings.
""" """
return oidc_user return oidc_user
...@@ -140,7 +140,7 @@ class WorkflowInstanceForTests(LazyWorkflowInstance): ...@@ -140,7 +140,7 @@ class WorkflowInstanceForTests(LazyWorkflowInstance):
This can be as simple as merely importing a workflow function. However, if it concerns a workflow generating This can be as simple as merely importing a workflow function. However, if it concerns a workflow generating
function, that function will be called with or without arguments as specified. function, that function will be called with or without arguments as specified.
Returns: A workflow function. :return Workflow: A workflow function.
""" """
self.workflow.name = self.name self.workflow.name = self.name
return self.workflow return self.workflow
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment