from api_graphql.abc.db_model_query_abc import DbModelQueryABC
from data.schemas.administration.api_key_dao import apiKeyDao
from data.schemas.permission.role_permission_dao import rolePermissionDao


class ApiKeyQuery(DbModelQueryABC):
    def __init__(self):
        DbModelQueryABC.__init__(self, "ApiKey", apiKeyDao, with_history=True)

        self.set_field("identifier", lambda x, *_: x.identifier)
        self.set_field("key", lambda x, *_: x.key)
        self.set_field("permissions", lambda x, *_: x.permissions)

        self.set_history_reference_dao(rolePermissionDao, "apikeyid")
