:py:mod:`dependencies` ====================== .. py:module:: dependencies .. autoapi-nested-parse:: Module that contains the methods used by FastApi dependency injection. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: dependencies.CheckDocumentPermission dependencies.CheckProjectPermission dependencies.CheckSystemPermission Functions ~~~~~~~~~ .. autoapisummary:: dependencies.get_session dependencies.create_db_and_tables dependencies.create_access_token dependencies.get_current_user dependencies.get_current_active_user dependencies.get_project dependencies.get_document dependencies.get_ms_project dependencies.require_document_permission dependencies.require_project_permission dependencies.require_system_permission dependencies.get_request_body dependencies.check_document_process dependencies.validate_document Attributes ~~~~~~~~~~ .. autoapisummary:: dependencies.oauth2_scheme dependencies.sqlite_file_name dependencies.sqlite_url dependencies.connect_args dependencies.engine .. py:data:: oauth2_scheme .. py:data:: sqlite_file_name :annotation: = ./db/database.db .. py:data:: sqlite_url .. py:data:: connect_args .. py:data:: engine .. py:function:: get_session() Get a session for the database :return: session .. py:function:: create_db_and_tables() Creates the database and tables .. py:function:: create_access_token(data, expires_delta = None) Creates an access token :param data: data to include in the token :param expires_delta: expiration time of token :return: token .. py:function:: get_current_user(token = Depends(oauth2_scheme), session = Depends(get_session)) :async: Gets the current user from the token :param token: token :param session: database session from dependencies :return: current user .. py:function:: get_current_active_user(current_user = Depends(get_current_user)) :async: Gets the current user from dependencies :param current_user: current user from dependencies :return: current user .. py:function:: get_project(project_name = None, session = Depends(get_session)) Gets the project named project_name from the database If project_name is None, returns None If project is not found, raises 404 exception :param project_name: project name, from path params :param session: database session from dependencies :return: project .. py:function:: get_document(project_name = None, document_name = None, session = Depends(get_session)) Gets the document named document_name from the database If project_name or document_name are None, returns None If document is not found, raises 404 exception :param project_name: project name, from path params :param document_name: document name, from path params :param session: database session from dependencies :return: document .. py:function:: get_ms_project(project_name = None, ms_project_name = None, session = Depends(get_session)) Gets the ms project named ms_project_name from the database If project_name or ms_project_name are None, returns None If ms_project is not found, raises 404 exception :param project_name: project name, from path params :param ms_project_name: ms project name, from path params :param session: database session from dependencies :return: ms project .. py:class:: CheckDocumentPermission(permission) Callable class that checks if user has permission on document .. py:method:: __call__(self, session = Depends(get_session), user = Depends(get_current_active_user), db_project = Depends(get_project), db_doc = Depends(get_document)) .. py:function:: require_document_permission(permission) Checks if user has permission on document, raises 401 if not authorized :param permission: permission to check .. py:class:: CheckProjectPermission(permission) Callable class that checks if user has permission on project .. py:method:: __call__(self, session = Depends(get_session), user = Depends(get_current_active_user), db_project = Depends(get_project)) .. py:function:: require_project_permission(permission) Checks if user has permission on project, raises 401 if not authorized :param permission: permission to check .. py:class:: CheckSystemPermission(permission) Callable class that checks if user has system permission .. py:method:: __call__(self, session = Depends(get_session), user = Depends(get_current_active_user)) .. py:function:: require_system_permission(permission) Checks if user has system permission, raises 401 if not authorized :param permission: permission to check .. py:function:: get_request_body(request) :async: Gets request body from request and returns it as dict, parsing both json and yaml :param request: request from body :return: dict with request body .. py:function:: check_document_process(db_doc = Depends(get_document)) Checks if document satisfies constraints of processes, raises 428 if not satisfied :param db_doc: document from path, returned by dependencies .. py:function:: validate_document(db_doc = Depends(get_document), document_body = Depends(get_request_body)) Validates document body against document schema, raises 400 if not valid :param db_doc: document from path, returned by dependencies :param document_body: document body from request