From 3ee7584f93e70b74d4074d15ce62d949158aefad Mon Sep 17 00:00:00 2001 From: Arne Bahlo Date: Thu, 12 Sep 2024 12:16:40 +0200 Subject: [PATCH 1/2] Revert "docs: Remove personal token mention from README" This reverts commit f2cbafb91c0344cc4fff31b1827e60ceec730477. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4f0c355..51af733 100644 --- a/README.md +++ b/README.md @@ -42,16 +42,16 @@ Alternatively, if you have the [`pip`](https://pip.pypa.io/) package installed, pip3 install axiom-py ``` -Create an API token with the permissions you need in the -[Axiom settings](https://cloud.axiom.co/profile) and export it as -`AXIOM_TOKEN`. +If you use the [Axiom CLI](https://github.com/axiomhq/cli), run `eval $(axiom config export -f)` to configure your environment variables. + +Otherwise create a personal token in [the Axiom settings](https://cloud.axiom.co/profile) and export it as `AXIOM_TOKEN`. Set `AXIOM_ORG_ID` to the organization ID from the settings page of the organization you want to access. You can also configure the client using options passed to the client constructor: ```py import axiom_py -client = axiom_py.Client("") +client = axiom_py.Client("", "") ``` Create and use a client like this: From 35e4f208108daef82662c0f8f66066ba7f9797c0 Mon Sep 17 00:00:00 2001 From: Arne Bahlo Date: Thu, 12 Sep 2024 12:17:38 +0200 Subject: [PATCH 2/2] feat: Upgrade users.current to v2 --- examples/client.py | 3 +++ src/axiom_py/users.py | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/examples/client.py b/examples/client.py index 3bd321c..2aaa444 100644 --- a/examples/client.py +++ b/examples/client.py @@ -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: diff --git a/src/axiom_py/users.py b/src/axiom_py/users.py index fe5ea5a..5cef077 100644 --- a/src/axiom_py/users.py +++ b/src/axiom_py/users.py @@ -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: @@ -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