Skip to content

Commit 6390253

Browse files
committed
add docs
1 parent acfadf8 commit 6390253

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

clerk/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
import aiohttp
66

7-
__all__ = ["Client", "Service"]
8-
97
from clerk.errors import ClerkAPIException
108

9+
__all__ = ["Client", "Service"]
10+
1111

1212
class Client:
13+
"""An API client for the clerk.dev API"""
14+
1315
def __init__(
1416
self, token: str, base_url: str = "https://api.clerk.dev/v1/", timeout_seconds: float = 30.0
1517
) -> None:

clerk/clients.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@ class ClientsService(Service):
99
verify_endpoint = endpoint + "/verify"
1010

1111
async def list(self) -> List[types.Client]:
12+
"""Retrieve a list of all clients"""
1213
async with self._client.get(self.endpoint) as r:
1314
return [types.Client.parse_obj(s) for s in await r.json()]
1415

1516
async def get(self, client_id: str) -> types.Client:
17+
"""Retrieve a client by its id"""
1618
async with self._client.get(f"{self.endpoint}/{client_id}") as r:
1719
return types.Client.parse_obj(await r.json())
1820

1921
async def verify(self, token: str) -> types.Client:
22+
"""Verify a token and return its associated client, if valid"""
2023
request = types.VerifyRequest(token=token)
2124

2225
async with self._client.post(self.verify_endpoint, data=request.json()) as r:

clerk/sessions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,22 @@ class SessionsService(Service):
88
endpoint = "sessions"
99

1010
async def list(self) -> List[types.Session]:
11+
"""Retrieve a list of all sessions"""
1112
async with self._client.get(self.endpoint) as r:
1213
return [types.Session.parse_obj(s) for s in await r.json()]
1314

1415
async def get(self, session_id: str) -> types.Session:
16+
"""Retrieve a session by its id"""
1517
async with self._client.get(f"{self.endpoint}/{session_id}") as r:
1618
return types.Session.parse_obj(await r.json())
1719

1820
async def revoke(self, session_id: str) -> types.Session:
21+
"""Revoke a session by its id"""
1922
async with self._client.post(f"{self.endpoint}/{session_id}/revoke") as r:
2023
return types.Session.parse_obj(await r.json())
2124

2225
async def verify(self, session_id: str, token: str) -> types.Session:
26+
"""Verify a session by its id and a given token"""
2327
request = types.VerifyRequest(token=token)
2428

2529
async with self._client.post(

clerk/users.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,22 @@ class UsersService(Service):
88
endpoint = "users"
99

1010
async def list(self) -> List[types.User]:
11+
"""Retrieve a list of all users"""
1112
async with self._client.get(self.endpoint) as r:
1213
return [types.User.parse_obj(s) for s in await r.json()]
1314

1415
async def get(self, user_id: str) -> types.User:
16+
"""Retrieve a user by their id"""
1517
async with self._client.get(f"{self.endpoint}/{user_id}") as r:
1618
return types.User.parse_obj(await r.json())
1719

1820
async def delete(self, user_id: str) -> types.DeleteUserResponse:
21+
"""Delete a user by their id"""
1922
async with self._client.delete(f"{self.endpoint}/{user_id}") as r:
2023
return types.DeleteUserResponse.parse_obj(await r.json())
2124

2225
async def update(self, user_id: str, request: types.UpdateUserRequest) -> types.User:
26+
"""Update a user by their id"""
2327
async with self._client.patch(
2428
f"{self.endpoint}/{user_id}", data=request.json(exclude_unset=True)
2529
) as r:

clerk/verification.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
class VerificationService(Service):
88
async def verify(self, session_token: str, session_id: Optional[str] = None) -> types.Session:
9+
"""Verify a session token and return the associated session, if any.
10+
11+
If a session_id is not passed then the client's last active session is returned.
12+
"""
913
if not session_id:
1014
client = await self._client.clients.verify(session_token)
1115
if not client.last_active_session_id:

0 commit comments

Comments
 (0)