mate.server.api.common module

mate.server.api.common.has_artifact(populated: Optional[bool] = None, kind: Optional[mate_common.models.artifacts.ArtifactKind] = None) Callable[[...], mate_query.db.Artifact]

Helper function to provide REST endpoint handlers with direct access to a particular artifact.

The populated parameter can be used to return an artifact only if it’s populated (True) or unpopulated (False). By default, the artifact is returned without checking.

The kind parameter can be used to return an artifact only if it’s of the specified ArtifactKind. By default, the artifact is returned without checking.

Parameters
Return type

Callable[[…], mate_query.db.Artifact]

mate.server.api.common.has_build(state: Optional[mate_common.models.builds.BuildState] = None) Callable[[...], mate_query.db.Build]

Helper function to provide REST endpoint handlers with direct access to a particular build.

The state parameter can be used to return a build if and only if it’s in the specified state.

Parameters

state (Optional[mate_common.models.builds.BuildState]) –

Return type

Callable[[…], mate_query.db.Build]

mate.server.api.common.has_compilation(state: Optional[mate_common.models.compilations.CompilationState] = None) Callable[[...], mate_query.db.Compilation]

Helper function to provide REST endpoint handlers with direct access to a particular compilation.

The state parameter can be used to return a build if and only if it’s in the specified state.

Parameters

state (Optional[mate_common.models.compilations.CompilationState]) –

Return type

Callable[[…], mate_query.db.Compilation]

mate.server.api.common.has_cpg(session: sqlalchemy.orm.session.Session = Depends(has_db), build: mate_query.db.Build = Depends(_has_build)) mate_query.db.Graph

Helper function to provide REST endpoint handlers with direct access to a particular CPG, identified by its build ID.

Parameters
Return type

mate_query.db.Graph

mate.server.api.common.has_db() sqlalchemy.orm.session.Session

Helper function to provide REST endpoint handlers with a database session.

This function should only be used in the type annotation of a session object in an endpoint handler.

Return type

sqlalchemy.orm.session.Session

mate.server.api.common.has_flowfinder_snapshot(snapshot_id: str, session: sqlalchemy.orm.session.Session = Depends(has_db)) mate_query.db.FlowFinderSnapshot

Helper function to provide REST endpoint handlers with direct access to a particular snapshot, identified by its ID.

Parameters
  • snapshot_id (str) –

  • session (sqlalchemy.orm.session.Session) –

Return type

mate_query.db.FlowFinderSnapshot

mate.server.api.common.has_mantiserve_task(state: Optional[mate_common.models.manticore.MantiserveTaskState] = None) Callable[[...], mate_query.db.MantiserveTask]

Helper function to provide REST endpoint handlers with direct access to a particular Mantiserve task, identified by its ID.

The state parameter can be used to return a Mantiserve task if and only if it’s in the specified state.

Parameters

state (Optional[mate_common.models.manticore.MantiserveTaskState]) –

Return type

Callable[[…], mate_query.db.MantiserveTask]

mate.server.api.common.has_poi_analysis(analysis_name: str) str

Helper function to provide REST endpoint handlers with direct access to a particular registered POI analysis, identified by its name.

Parameters

analysis_name (str) –

Return type

str

mate.server.api.common.has_poi_result(poi_id: str, session: sqlalchemy.orm.session.Session = Depends(has_db)) mate_query.db.POIResult

Helper function to provide REST endpoint handlers with direct access to a particular POI result, identified by its POI result ID.

Parameters
  • poi_id (str) –

  • session (sqlalchemy.orm.session.Session) –

Return type

mate_query.db.POIResult

mate.server.api.common.save_file_to_server(file: fastapi.datastructures.UploadFile, server_path: pathlib.Path) None

Persists temporary UploadFiles to server_path.

Note: if this operation fails fastapi will automatically log the traceback and return a 500 internal server error, so we don’t need a try/catch block here.

Parameters
  • file (fastapi.datastructures.UploadFile) –

  • server_path (pathlib.Path) –

Return type

None