Skip to content

get_all_deployment_auth_tokens

fastagency.studio.app.get_all_deployment_auth_tokens async #

get_all_deployment_auth_tokens(
    user_uuid: str, deployment_uuid: str
) -> list[DeploymentAuthTokenInfo]
Source code in fastagency/studio/app.py
@app.get("/user/{user_uuid}/deployment/{deployment_uuid}")
async def get_all_deployment_auth_tokens(
    user_uuid: str, deployment_uuid: str
) -> list[DeploymentAuthTokenInfo]:
    user = await DefaultDB.frontend().get_user(user_uuid=user_uuid)
    deployment = await DefaultDB.backend().find_model(model_uuid=deployment_uuid)

    if user["uuid"] != deployment["user_uuid"]:
        raise HTTPException(  # pragma: no cover
            status_code=403, detail="User does not have access to this deployment"
        )

    auth_tokens = await DefaultDB.backend().find_many_auth_token(
        user_uuid=user_uuid, deployment_uuid=deployment_uuid
    )
    return [
        DeploymentAuthTokenInfo(
            uuid=auth_token["uuid"],
            name=auth_token["name"],
            expiry=auth_token["expiry"],
        )
        for auth_token in auth_tokens
    ]