Fix linting
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
from fastapi import APIRouter, Depends, Request
|
||||
from fastapi import APIRouter, Depends
|
||||
from pydantic import BaseModel, Field, TypeAdapter
|
||||
from sqlalchemy import select, func, and_
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
@ -22,7 +22,7 @@ from sshecret_backend.view_models import (
|
||||
)
|
||||
from sshecret_backend import audit
|
||||
from sshecret_backend.types import AsyncDBSessionDep
|
||||
from .common import get_client_by_id_or_name
|
||||
from .common import get_client_by_id_or_name, get_client_by_name
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -146,7 +146,7 @@ def get_secrets_api(get_db_session: AsyncDBSessionDep) -> APIRouter:
|
||||
session: Annotated[AsyncSession, Depends(get_db_session)],
|
||||
) -> None:
|
||||
"""Delete a secret."""
|
||||
client = await get_client_by_id_or_name(session, name)
|
||||
client = await get_client_by_name(session, name)
|
||||
if not client:
|
||||
raise HTTPException(
|
||||
status_code=404, detail="Cannot find a client with the given name."
|
||||
@ -217,8 +217,10 @@ def get_secrets_api(get_db_session: AsyncDBSessionDep) -> APIRouter:
|
||||
clients: list[str] = []
|
||||
client_secrets = await session.scalars(
|
||||
select(ClientSecret)
|
||||
.join(ClientSecret.client)
|
||||
.options(selectinload(ClientSecret.client))
|
||||
.where(ClientSecret.name == name)
|
||||
.where(Client.is_active.is_(True))
|
||||
)
|
||||
for client_secret in client_secrets.all():
|
||||
if not client_secret.client:
|
||||
@ -235,7 +237,10 @@ def get_secrets_api(get_db_session: AsyncDBSessionDep) -> APIRouter:
|
||||
"""Get a list of which clients has a named secret."""
|
||||
detail_list = ClientSecretDetailList(name=name)
|
||||
client_secrets = await session.scalars(
|
||||
select(ClientSecret).where(ClientSecret.name == name)
|
||||
select(ClientSecret)
|
||||
.options(selectinload(ClientSecret.client))
|
||||
.where(ClientSecret.name == name)
|
||||
.where(ClientSecret.client.is_(Client.is_active))
|
||||
)
|
||||
for client_secret in client_secrets.all():
|
||||
if not client_secret.client:
|
||||
|
||||
Reference in New Issue
Block a user