text: from fastapi import APIRouter, Depends, Path, Response, status
  from fastapi_pagination import Page
  
  from .. import deps
  from ..schemas import Note, NoteIn, UserInDb
  from ..services import AuthService, NoteService
  
  
  router = APIRouter(prefix="/notes", tags=["notes"])
  
  
  @router.get(
      "", dependencies=[Depends(deps.get_current_superuser)], response_model=Page[Note]
  )
  async def get_notes(note_service: NoteService = Depends(deps.get_note_service)):
      return await note_service.get_notes()
  
  
  @router.post(
      "",
      status_code=status.HTTP_201_CREATED,
      response_model=Note,
      responses={
          404: {"description": "Note Not Found"},
      },
  )
  async def create_note(
      *,
      current_user: UserInDb = Depends(deps.get_current_user),
      note_in: NoteIn,
      note_service: NoteService = Depends(deps.get_note_service),
  ):
      AuthService.owner_or_superuser_required(current_user, note_in.user_id)
      return await note_service.create(note_in)
  
  
  @router.get(
      "/{note_id}",
      response_model=Note,
      responses={
          404: {"description": "Note Not Found"},
      },
  )
  async def get_note(
      current_user: UserInDb = Depends(deps.get_current_user),
      note_id: int = Path(..., ge=1),
      note_service: NoteService = Depends(deps.get_note_service),
  ):
      note = await note_service.get_note(note_id)
      AuthService.owner_or_superuser_required(current_user, note.user_id)
      return note
  
  
  @router.put(
      "/{note_id}",
      status_code=204,
      responses={
          201: {},
          404: {"description": "Note Not Found"},
      },
  )
  async def update_note(
      *,
      response: Response,
      current_user: UserInDb = Depends(deps.get_current_user),
      note_id: int = Path(..., ge=1),
      note_in: NoteIn,
      note_service: NoteService = Depends(deps.get_note_service),
  ):
      AuthService.owner_or_superuser_required(current_user, note_in.user_id)
      note = await note_service.create_or_update(note_id, note_in)
      if note:
          response.status_code = 201
          return note
  
  
  @router.delete(
      "/{note_id}",
      status_code=204,
      responses={
          404: {"description": "Note Not Found"},
      },
  )
  async def remove_note(
      current_user: UserInDb = Depends(deps.get_current_user),
      note_id: int = Path(..., ge=1),
      note_service: NoteService = Depends(deps.get_note_service),
  ):
      note = await note_service.get_note(note_id)
      AuthService.owner_or_superuser_required(current_user, note.user_id)
      await note_service.remove(note_id)
  