Skip to content

Commit

Permalink
feat: Upgrade users.current to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
bahlo committed Sep 12, 2024
1 parent 3ee7584 commit 35e4f20
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions examples/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ def main():
client = Client()
dataset_name = "my-dataset"

# Get current user
print(client.users.current())

# List datasets
res = client.datasets.get_list()
for dataset in res:
Expand Down
12 changes: 9 additions & 3 deletions src/axiom_py/users.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
from typing import List
from .util import Util
from dataclasses import dataclass
from requests import Session


@dataclass
class Role:
id: str
name: str


@dataclass
class User:
"""An authenticated axiom user."""

id: str
name: str
emails: List[str]
email: str
role: Role


class UsersClient:
Expand All @@ -25,6 +31,6 @@ def current(self) -> User:

See https://axiom.co/docs/restapi/endpoints/getCurrentUser
"""
res = self.session.get("/v1/user")
res = self.session.get("/v2/user")
user = Util.from_dict(User, res.json())
return user

0 comments on commit 35e4f20

Please sign in to comment.