ahriman.core.database.operations package

Submodules

ahriman.core.database.operations.auth_operations module

class AuthOperations(path: Path, configuration: Configuration)

Bases: Operations

authorization operations

Parameters:
  • path (Path) – path to the database file

  • configuration (Configuration) – configuration instance

user_get(username: str) User | None

get user by username

Parameters:

username (str) – username

Returns:

user if it was found

Return type:

User | None

user_list(username: str | None, access: UserAccess | None) list[User]

get users by filter

Parameters:
  • username (str | None) – optional filter by username

  • access (UserAccess | None) – optional filter by role

Returns:

list of users who match criteria

Return type:

list[User]

user_remove(username: str) None

remove user from storage

Parameters:

username (str) – username

user_update(user: User) None

update user by username

Parameters:

user (User) – user descriptor

ahriman.core.database.operations.build_operations module

class BuildOperations(path: Path, configuration: Configuration)

Bases: Operations

operations for build queue functions

Parameters:
  • path (Path) – path to the database file

  • configuration (Configuration) – configuration instance

build_queue_clear(package_base: str | None, repository_id: RepositoryId | None = None) None

remove packages from build queue

Parameters:
  • package_base (str | None) – optional filter by package base

  • repository_id (RepositoryId, optional) – repository unique identifier override (Default value = None)

build_queue_get(repository_id: RepositoryId | None = None) list[Package]

retrieve packages from build queue

Parameters:

repository_id (RepositoryId, optional) – repository unique identifier override (Default value = None)

Returns:

list of packages to be built

Return type:

list[Package]

build_queue_insert(package: Package, repository_id: RepositoryId | None = None) None

insert packages to build queue

Parameters:
  • package (Package) – package to be inserted

  • repository_id (RepositoryId, optional) – repository unique identifier override (Default value = None)

ahriman.core.database.operations.changes_operations module

class ChangesOperations(path: Path, configuration: Configuration)

Bases: Operations

operations for source files changes

Parameters:
  • path (Path) – path to the database file

  • configuration (Configuration) – configuration instance

changes_get(package_base: str, repository_id: RepositoryId | None = None) Changes

get changes for the specific package base if available

Parameters:
  • package_base (str) – package base to search

  • repository_id (RepositoryId, optional) – repository unique identifier override (Default value = None)

Returns:

changes for the package base if available

Return type:

Changes

changes_insert(package_base: str, changes: Changes, repository_id: RepositoryId | None = None) None

insert package changes

Parameters:
  • package_base (str) – package base to insert

  • changes (Changes) – package changes (as in patch format)

  • repository_id (RepositoryId, optional) – repository unique identifier override (Default value = None)

changes_remove(package_base: str | None, repository_id: RepositoryId | None = None) None

remove packages changes

Parameters:
  • package_base (str | None) – optional filter by package base

  • repository_id (RepositoryId, optional) – repository unique identifier override (Default value = None)

ahriman.core.database.operations.dependencies_operations module

class DependenciesOperations(path: Path, configuration: Configuration)

Bases: Operations

operations for dependencies table

Parameters:
  • path (Path) – path to the database file

  • configuration (Configuration) – configuration instance

dependencies_get(package_base: str | None = None, repository_id: RepositoryId | None = None) dict[str, Dependencies]

get dependencies for the specific package base if available

Parameters:
  • package_base (str | None) – package base to search

  • repository_id (RepositoryId, optional) – repository unique identifier override (Default value = None)

Returns:

dependencies for the package base if available

Return type:

Dependencies

dependencies_insert(package_base: str, dependencies: Dependencies, repository_id: RepositoryId | None = None) None

insert package dependencies

Parameters:
  • package_base (str) – package base

  • dependencies (Dependencies) – package dependencies

  • repository_id (RepositoryId, optional) – repository unique identifier override (Default value = None)

dependencies_remove(package_base: str | None, repository_id: RepositoryId | None = None) None

remove packages dependencies

Parameters:
  • package_base (str | None) – optional filter by package base

  • repository_id (RepositoryId, optional) – repository unique identifier override (Default value = None)

ahriman.core.database.operations.event_operations module

class EventOperations(path: Path, configuration: Configuration)

Bases: Operations

operations for audit log table

Parameters:
  • path (Path) – path to the database file

  • configuration (Configuration) – configuration instance

event_get(event: str | EventType | None = None, object_id: str | None = None, from_date: int | float | None = None, to_date: int | float | None = None, limit: int = -1, offset: int = 0, repository_id: RepositoryId | None = None) list[Event]

get list of events with filters applied

Parameters:
  • event (str | EventType | None, optional) – filter by event type (Default value = None)

  • object_id (str | None, optional) – filter by event object (Default value = None)

  • from_date (int | float | None, optional) – minimal creation date, inclusive (Default value = None)

  • to_date (int | float | None, optional) – maximal creation date, exclusive (Default value = None)

  • limit (int, optional) – limit records to the specified count, -1 means unlimited (Default value = -1)

  • offset (int, optional) – records offset (Default value = 0)

  • repository_id (RepositoryId, optional) – repository unique identifier override (Default value = None)

Returns:

list of audit log events

Return type:

list[Event]

event_insert(event: Event, repository_id: RepositoryId | None = None) None

insert audit log event

Parameters:
  • event (Event) – event to insert

  • repository_id (RepositoryId, optional) – repository unique identifier override (Default value = None)

ahriman.core.database.operations.logs_operations module

class LogsOperations(path: Path, configuration: Configuration)

Bases: Operations

logs operations

Parameters:
  • path (Path) – path to the database file

  • configuration (Configuration) – configuration instance

logs_get(package_base: str, version: str | None = None, process_id: str | None = None, limit: int = -1, offset: int = 0, repository_id: RepositoryId | None = None) list[LogRecord]

extract logs for specified package base

Parameters:
  • package_base (str) – package base to extract logs

  • version (str | None, optional) – package version to filter (Default value = None)

  • process_id (str | None, optional) – process identifier to filter (Default value = None)

  • limit (int, optional) – limit records to the specified count, -1 means unlimited (Default value = -1)

  • offset (int, optional) – records offset (Default value = 0)

  • repository_id (RepositoryId, optional) – repository unique identifier override (Default value = None)

Returns:

sorted package log records

Return type:

list[LogRecord]

logs_insert(log_record: LogRecord, repository_id: RepositoryId | None = None) None

write new log record to database

Parameters:
  • log_record (LogRecord) – log record object

  • repository_id (RepositoryId, optional) – repository unique identifier override (Default value = None)

logs_remove(package_base: str, version: str | None, repository_id: RepositoryId | None = None) None

remove log records for the specified package

Parameters:
  • package_base (str) – package base to remove logs

  • version (str | None) – package version. If set it will remove only logs belonging to another version

  • repository_id (RepositoryId, optional) – repository unique identifier override (Default value = None)

logs_rotate(keep_last_records: int, repository_id: RepositoryId | None = None) None

rotate logs in storage. This method will remove old logs, keeping only the last N records for each package

Parameters:
  • keep_last_records (int) – number of last records to keep

  • repository_id (RepositoryId, optional) – repository unique identifier override (Default value = None)

ahriman.core.database.operations.operations module

class Operations(path: Path, configuration: Configuration)

Bases: LazyLogging

base operation class

path

path to the database file

Type:

Path

Parameters:
  • path (Path) – path to the database file

  • configuration (Configuration) – configuration instance

static factory(cursor: Cursor, row: tuple[Any, ...]) dict[str, Any]

dictionary factory based on official documentation

Parameters:
  • cursor (Cursor) – cursor descriptor

  • row (tuple[Any, ...]) – fetched row

Returns:

row converted to dictionary

Return type:

dict[str, Any]

with_connection(query: Callable[[Connection], T], *, commit: bool = False) T

perform operation in connection

Parameters:
  • query (Callable[[Connection], T]) – function to be called with connection

  • commit (bool, optional) – if True commit() will be called on success (Default value = False)

Returns:

result of the query call

Return type:

T

property logger_name: str

extract logger name for the class

Returns:

logger name override

Return type:

str

ahriman.core.database.operations.package_operations module

class PackageOperations(path: Path, configuration: Configuration)

Bases: Operations

package operations

Parameters:
  • path (Path) – path to the database file

  • configuration (Configuration) – configuration instance

package_remove(package_base: str, repository_id: RepositoryId | None = None) None

remove package from database

Parameters:
  • package_base (str) – package base name

  • repository_id (RepositoryId, optional) – repository unique identifier override (Default value = None)

package_update(package: Package, repository_id: RepositoryId | None = None) None

update package status

Parameters:
  • package (Package) – package properties

  • repository_id (RepositoryId, optional) – repository unique identifier override (Default value = None)

packages_get(repository_id: RepositoryId | None = None) list[tuple[Package, BuildStatus]]

get package list and their build statuses from database

Parameters:

repository_id (RepositoryId, optional) – repository unique identifier override (Default value = None)

Returns:

list of package properties and their statuses

Return type:

list[tuple[Package, BuildStatus]]

status_update(package_base: str, status: BuildStatus, repository_id: RepositoryId | None = None) None

insert base package status into table

Parameters:
  • package_base (str) – package base name

  • status (BuildStatus) – new build status

  • repository_id (RepositoryId, optional) – repository unique identifier override (Default value = None)

ahriman.core.database.operations.patch_operations module

class PatchOperations(path: Path, configuration: Configuration)

Bases: Operations

operations for patches

Parameters:
  • path (Path) – path to the database file

  • configuration (Configuration) – configuration instance

patches_get(package_base: str) list[PkgbuildPatch]

retrieve patches for the package

Parameters:

package_base (str) – package base to search for patches

Returns:

plain text patch for the package

Return type:

list[PkgbuildPatch]

patches_insert(package_base: str, patches: list[PkgbuildPatch]) None

insert or update patch in database

Parameters:
  • package_base (str) – package base to insert

  • patches (list[PkgbuildPatch]) – patch content

patches_list(package_base: str | None, variables: list[str] | None) dict[str, list[PkgbuildPatch]]

extract all patches

Parameters:
  • package_base (str | None) – optional filter by package base

  • variables (list[str] | None) – extract patches only for specified PKGBUILD variables

Returns:

map of package base to patch content

Return type:

dict[str, list[PkgbuildPatch]]

patches_remove(package_base: str, variables: list[str] | None) None

remove patch set

Parameters:
  • package_base (str) – package base to clear patches

  • variables (list[str] | None) – remove patches only for specified PKGBUILD variables

Module contents