c889a57b6b
Test Suites / Build CI Environment (push) Has been cancelled
Test Suites / Basic Tests (push) Has been cancelled
Test Suites / End-to-End Tests (push) Has been cancelled
Test Suites / CLI Tests (push) Has been cancelled
Test Suites / Slow End-to-End Tests (push) Has been cancelled
Test Suites / Graph Database Tests (push) Has been cancelled
Test Suites / Vector DB Tests (push) Has been cancelled
Test Suites / Temporal Graph Test (push) Has been cancelled
Test Suites / Search Test on Different DBs (push) Has been cancelled
Test Suites / Example Tests (push) Has been cancelled
Test Suites / Notebook Tests (push) Has been cancelled
Test Suites / OS and Python Tests Ubuntu (push) Has been cancelled
Test Suites / OS and Python Tests Extended (push) Has been cancelled
Test Suites / LLM Test Suite (push) Has been cancelled
Test Suites / S3 File Storage Test (push) Has been cancelled
Test Suites / Run Integration Tests (push) Has been cancelled
Test Suites / MCP Tests (push) Has been cancelled
Test Suites / Docker Compose Test (push) Has been cancelled
Test Suites / Docker CI test (push) Has been cancelled
Test Suites / Relational DB Migration Tests (push) Has been cancelled
Test Suites / Distributed Cognee Test (push) Has been cancelled
Test Suites / DB Examples Tests (push) Has been cancelled
Test Suites / Test Completion Status (push) Has been cancelled
Test Suites / Claude Code Review (push) Has been cancelled
Test Suites / basic checks (push) Has been cancelled
build | Build and Push Cognee MCP Docker Image to dockerhub / docker-build-and-push (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
build | Build and Push Docker Image to dockerhub / docker-build-and-push (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Core Functionality (3.11) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Core Functionality (3.12) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges with Different Graph Databases (kuzu, kuzu) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges with Different Graph Databases (neo4j, neo4j) (push) Has been cancelled
Weighted Edges Tests / Test Weighted Edges Examples (push) Has been cancelled
Weighted Edges Tests / Code Quality for Weighted Edges (push) Has been cancelled
52 lines
1.9 KiB
Python
52 lines
1.9 KiB
Python
from sqlalchemy import select
|
|
from uuid import UUID
|
|
from cognee.infrastructure.databases.relational import get_relational_engine
|
|
from cognee.modules.users.models.PrincipalConfiguration import PrincipalConfiguration
|
|
|
|
|
|
async def get_principal_configuration(config_id: UUID) -> dict:
|
|
"""
|
|
Retrieves a specific Cognee configuration for a principal by its name.
|
|
|
|
Args:
|
|
config_id (str): The unique identifier of the config.
|
|
|
|
Returns:
|
|
dict: The configuration data if found, or an empty dictionary (or None) if not found.
|
|
"""
|
|
relational_engine = get_relational_engine()
|
|
async with relational_engine.get_async_session() as session:
|
|
query = select(PrincipalConfiguration).where(PrincipalConfiguration.id == config_id)
|
|
|
|
result = await session.execute(query)
|
|
config_record = result.scalars().first()
|
|
|
|
# Return the configuration dictionary if the record exists, otherwise an empty dict
|
|
return config_record.configuration if config_record else {}
|
|
|
|
|
|
async def get_principal_all_configuration(principal_id: UUID) -> list[dict[str, dict]]:
|
|
"""
|
|
Retrieves all Cognee configurations for a specific principal.
|
|
|
|
Args:
|
|
principal_id (UUID): The unique identifier of the owner (user/group).
|
|
|
|
Returns:
|
|
list[dict]: A list of configuration dictionaries. Returns an empty list if none are found.
|
|
"""
|
|
relational_engine = get_relational_engine()
|
|
|
|
async with relational_engine.get_async_session() as session:
|
|
# Select all records belonging to the principal
|
|
query = select(PrincipalConfiguration).where(
|
|
PrincipalConfiguration.owner_id == principal_id
|
|
)
|
|
|
|
result = await session.execute(query)
|
|
# Fetch all records from the result
|
|
config_records = result.scalars().all()
|
|
|
|
# Extract the configuration dictionary from each record
|
|
return [config_records.to_json() for config_records in config_records]
|