Skip to content

Commit

Permalink
Code reformatting and fix spelling errors
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartcampbell committed Oct 13, 2023
1 parent 946c2d7 commit d71a144
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions nsls2api/api/v1/admin_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,34 @@
from fastapi import Depends

from nsls2api.infrastructure import config
from nsls2api.infrastructure.security import validate_admin_role, generate_api_key
from nsls2api.infrastructure.security import (
validate_admin_role,
generate_api_key,
)
from nsls2api.models.apikeys import ApiUser

# router = fastapi.APIRouter()
router = fastapi.APIRouter(dependencies=[Depends(validate_admin_role)])


@router.get("/admin/settings")#, include_in_schema=False)
@router.get("/admin/settings") # , include_in_schema=False)
async def info(
settings: Annotated[config.Settings, Depends(config.get_settings)]
):
return settings
@router.get('/admim/validate', response_model=str)
async def check_admin_validation(admin_user: Annotated[ApiUser, Depends(validate_admin_role)] = None):


@router.get("/admin/validate", response_model=str)
async def check_admin_validation(
admin_user: Annotated[ApiUser, Depends(validate_admin_role)] = None
):
"""
:param admin_user: - The admin user to be checked for validation.
:return: str - The username of the validated admin user.
"""
return admin_user.username


@router.post('/admin/generate_api_key/{username}')
@router.post("/admin/generate_api_key/{username}")
async def generate_user_apikey(username: str):
"""
Generate an API key for a given username.
Expand All @@ -34,8 +40,3 @@ async def generate_user_apikey(username: str):
:return: The generated API key.
"""
return await generate_api_key(username)



# The following endpoints are 'pass-through' routes to underlying services
# They are here for convenience only

0 comments on commit d71a144

Please sign in to comment.