Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Update routers.py #1

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions API/auth/routers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ def login_url(request: Request):
Returns:
- login_url (dict) - URL to authorize user to the application via. Openstreetmap
OAuth2 with client_id, redirect_uri, and permission scope as query_string parameters

Example response:
{
"login_url": "https://www.openstreetmap.org/oauth2/authorize?client_id=...&redirect_uri=...&scope=..."
}
"""
login_url = osm_auth.login()
return login_url
Expand All @@ -36,6 +41,9 @@ def callback(request: Request):

Returns:
- access_token (string)

Example response:
"abcdef0123456789"
"""
access_token = osm_auth.callback(str(request.url))

Expand All @@ -54,6 +62,13 @@ def my_data(user_data: AuthUser = Depends(login_required)):
ADMIN = 1
STAFF = 2
GUEST = 3

Example response:
{
"osm_id": 123456,
"display_name": "John Doe",
"role": 2
}
"""
return user_data

Expand All @@ -79,6 +94,11 @@ async def create_user(params: User, user_data: AuthUser = Depends(admin_required
Returns:
- Dict[str, Any]: A dictionary containing the osm_id of the newly created user.

Example response:
{
"osm_id": 123456
}

Raises:
- HTTPException: If the user creation fails.
"""
Expand All @@ -102,6 +122,12 @@ async def read_user(osm_id: int, user_data: AuthUser = Depends(staff_required)):
Returns:
- Dict[str, Any]: A dictionary containing user information.

Example response:
{
"osm_id": 654321,
"role": 2
}

Raises:
- HTTPException: If the user with the given osm_id is not found.
"""
Expand All @@ -128,6 +154,18 @@ async def update_user(
Returns:
- Dict[str, Any]: A dictionary containing the updated user information.

Example request body:
{
"osm_id": 123456,
"role": 1
}

Example response:
{
"osm_id": 123456,
"role": 1
}

Raises:
- HTTPException: If the user with the given osm_id is not found.
"""
Expand All @@ -144,6 +182,11 @@ async def delete_user(osm_id: int, user_data: AuthUser = Depends(admin_required)
Args:
- osm_id (int): The OSM ID of the user to delete.

Example response:
{
"osm_id": 123456,
}

Returns:
- Dict[str, Any]: A dictionary containing the deleted user information.

Expand All @@ -168,6 +211,18 @@ async def read_users(

Returns:
- List[Dict[str, Any]]: A list of dictionaries containing user information.

Example response:
[
{
"osm_id": 123456,
"role": 1
},
{
"osm_id": 654321,
"role": 2
},
]
"""
auth = Users()
return auth.read_users(skip, limit)