From dfaf971176f2772c7800cdfb6953d45fb6079373 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Feb 2024 02:55:26 +0000 Subject: [PATCH 01/16] Update responses requirement from ^0.23.1 to ^0.25.0 Updates the requirements on [responses](https://github.com/getsentry/responses) to permit the latest version. - [Release notes](https://github.com/getsentry/responses/releases) - [Changelog](https://github.com/getsentry/responses/blob/master/CHANGES) - [Commits](https://github.com/getsentry/responses/compare/0.23.1...0.25.0) --- updated-dependencies: - dependency-name: responses dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5f008ba..4e30551 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,7 +25,7 @@ iso8601 = ">=1.0.2,<3.0.0" black = "^23.3.0" pytest = "^7.3.2" pylint = "^2.7.2" -responses = "^0.23.1" +responses = "^0.25.0" [build-system] requires = ["poetry-core>=1.0.0"] From 344043d122cde92f8a7d4be925a0232b540f0935 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Apr 2024 02:06:46 +0000 Subject: [PATCH 02/16] Update black requirement from ^23.3.0 to ^24.4.2 Updates the requirements on [black](https://github.com/psf/black) to permit the latest version. - [Release notes](https://github.com/psf/black/releases) - [Changelog](https://github.com/psf/black/blob/main/CHANGES.md) - [Commits](https://github.com/psf/black/compare/23.3.0...24.4.2) --- updated-dependencies: - dependency-name: black dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5f008ba..734bf0d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,7 +22,7 @@ rfc3339 = "^6.2" iso8601 = ">=1.0.2,<3.0.0" [tool.poetry.dev-dependencies] -black = "^23.3.0" +black = "^24.4.2" pytest = "^7.3.2" pylint = "^2.7.2" responses = "^0.23.1" From e66e502ac02f160ae062b41ecc821b83681f6d20 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 02:15:59 +0000 Subject: [PATCH 03/16] Update pytest requirement from ^7.3.2 to ^8.2.1 Updates the requirements on [pytest](https://github.com/pytest-dev/pytest) to permit the latest version. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/7.3.2...8.2.1) --- updated-dependencies: - dependency-name: pytest dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5f008ba..73780b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ iso8601 = ">=1.0.2,<3.0.0" [tool.poetry.dev-dependencies] black = "^23.3.0" -pytest = "^7.3.2" +pytest = "^8.2.1" pylint = "^2.7.2" responses = "^0.23.1" From c3f21701f16ccd3da60b2d5b48eb1ad887b6c5f1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 May 2024 02:16:28 +0000 Subject: [PATCH 04/16] Update pylint requirement from ^2.7.2 to ^3.2.1 Updates the requirements on [pylint](https://github.com/pylint-dev/pylint) to permit the latest version. - [Release notes](https://github.com/pylint-dev/pylint/releases) - [Commits](https://github.com/pylint-dev/pylint/compare/pylint-2.7.2...v3.2.1) --- updated-dependencies: - dependency-name: pylint dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 5f008ba..02ad08c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ iso8601 = ">=1.0.2,<3.0.0" [tool.poetry.dev-dependencies] black = "^23.3.0" pytest = "^7.3.2" -pylint = "^2.7.2" +pylint = "^3.2.1" responses = "^0.23.1" [build-system] From 0630c4e17c36c5031e34716070dd748d81a80514 Mon Sep 17 00:00:00 2001 From: Luna <105922175+ImLunaHey@users.noreply.github.com> Date: Mon, 15 Jul 2024 09:22:34 +0930 Subject: [PATCH 05/16] chore: new repo banner --- README.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e1ef381..14446e0 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,19 @@ -![axiom-py: The official Python bindings for the Axiom API](.github/images/banner-dark.svg#gh-dark-mode-only) -![axiom-py: The official Python bindings for the Axiom API](.github/images/banner-light.svg#gh-light-mode-only) - -
+# axiom-py + + + + + + + Axiom.co banner + + +  [![CI][ci_badge]][ci] [![PyPI version][pypi_badge]][pypi] [![Python version][version_badge]][pypi] -
- [Axiom](https://axiom.co) unlocks observability at any scale. - **Ingest with ease, store without limits:** Axiom’s next-generation datastore enables ingesting petabytes of data with ultimate efficiency. Ship logs from Kubernetes, AWS, Azure, Google Cloud, DigitalOcean, Nomad, and others. From 1eb58939a597f39ae44e7387fbefc74b2b5eab1e Mon Sep 17 00:00:00 2001 From: Marcel Jackwerth Date: Fri, 16 Aug 2024 14:04:51 +0000 Subject: [PATCH 06/16] feat(typing): Prefer object over Any --- axiom/client.py | 10 +++++----- axiom/query/result.py | 8 ++++---- tests/test_annotations.py | 2 +- tests/test_datasets.py | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/axiom/client.py b/axiom/client.py index 6f94861..0d60c3b 100644 --- a/axiom/client.py +++ b/axiom/client.py @@ -8,7 +8,7 @@ from .util import Util from enum import Enum from humps import decamelize -from typing import Optional, List, Dict, Any +from typing import Optional, List, Dict from logging import getLogger from dataclasses import dataclass, field, asdict from datetime import datetime @@ -267,7 +267,7 @@ def query(self, apl: str, opts: Optional[AplOptions] = None) -> QueryResult: result.savedQueryID = query_id return result - def _prepare_query_options(self, opts: QueryOptions) -> Dict[str, Any]: + def _prepare_query_options(self, opts: QueryOptions) -> Dict[str, object]: """returns the query options as a Dict, handles any renaming for key fields.""" if opts is None: return {} @@ -283,7 +283,7 @@ def _prepare_query_options(self, opts: QueryOptions) -> Dict[str, Any]: return params - def _prepare_ingest_options(self, opts: Optional[IngestOptions]) -> Dict[str, Any]: + def _prepare_ingest_options(self, opts: Optional[IngestOptions]) -> Dict[str, object]: """the query params for ingest api are expected in a format that couldn't be defined as a variable name because it has a dash. As a work around, we create the params dict manually.""" @@ -301,7 +301,7 @@ def _prepare_ingest_options(self, opts: Optional[IngestOptions]) -> Dict[str, An return params - def _prepare_apl_options(self, opts: Optional[AplOptions]) -> Dict[str, Any]: + def _prepare_apl_options(self, opts: Optional[AplOptions]) -> Dict[str, object]: """Prepare the apl query options for the request.""" params = {} @@ -320,7 +320,7 @@ def _prepare_apl_options(self, opts: Optional[AplOptions]) -> Dict[str, Any]: def _prepare_apl_payload( self, apl: str, opts: Optional[AplOptions] - ) -> Dict[str, Any]: + ) -> Dict[str, object]: """Prepare the apl query options for the request.""" params = {} params["apl"] = apl diff --git a/axiom/query/result.py b/axiom/query/result.py index 3917230..95a585c 100644 --- a/axiom/query/result.py +++ b/axiom/query/result.py @@ -1,6 +1,6 @@ from dataclasses import dataclass, field from datetime import datetime, timedelta -from typing import List, Dict, Any, Optional +from typing import List, Dict, Optional from enum import Enum from .query import QueryLegacy @@ -87,7 +87,7 @@ class Entry: _rowId: str # contains the raw data of the event (with filters and aggregations # applied). - data: Dict[str, Any] + data: Dict[str, object] @dataclass @@ -96,7 +96,7 @@ class EntryGroupAgg: # alias is the aggregations alias. If it wasn't specified at query time, it # is the uppercased string representation of the aggregation operation. - value: Any + value: object op: str = field(default="") # value is the result value of the aggregation. @@ -108,7 +108,7 @@ class EntryGroup: # the unique id of the group. id: int # group maps the fieldnames to the unique values for the entry. - group: Dict[str, Any] + group: Dict[str, object] # aggregations of the group. aggregations: List[EntryGroupAgg] diff --git a/tests/test_annotations.py b/tests/test_annotations.py index ed23490..e658372 100644 --- a/tests/test_annotations.py +++ b/tests/test_annotations.py @@ -3,7 +3,7 @@ import os import unittest -from typing import List, Dict, Any, Optional +from typing import List, Dict, Optional from logging import getLogger from requests.exceptions import HTTPError from datetime import timedelta diff --git a/tests/test_datasets.py b/tests/test_datasets.py index 8375f61..c7c4c33 100644 --- a/tests/test_datasets.py +++ b/tests/test_datasets.py @@ -3,7 +3,7 @@ import os import unittest -from typing import List, Dict, Any +from typing import List, Dict from logging import getLogger from requests.exceptions import HTTPError from datetime import timedelta @@ -17,7 +17,7 @@ class TestDatasets(unittest.TestCase): dataset_name: str - events: List[Dict[str, Any]] + events: List[Dict[str, object]] client: Client events_time_format = "%d/%b/%Y:%H:%M:%S +0000" From 963c0b30062217395eef3081b6a92785f1fe245d Mon Sep 17 00:00:00 2001 From: Arne Bahlo Date: Fri, 6 Sep 2024 17:18:50 +0200 Subject: [PATCH 07/16] feat: Add cursor, includeCursor options This also removes the `no_cache` and `save` flags as they are undocumented. --- axiom/client.py | 25 ++++++++++++++----------- tests/test_client.py | 2 -- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/axiom/client.py b/axiom/client.py index 6f94861..6b1daca 100644 --- a/axiom/client.py +++ b/axiom/client.py @@ -98,11 +98,18 @@ class WrongQueryKindException(Exception): class AplOptions: """AplOptions specifies the optional parameters for the apl query method.""" + # Start time for the interval to query. start_time: Optional[datetime] = field(default=None) + # End time for the interval to query. end_time: Optional[datetime] = field(default=None) - no_cache: bool = field(default=False) - save: bool = field(default=False) + # The result format. format: AplResultFormat = field(default=AplResultFormat.Legacy) + # Cursor is the query cursor. It should be set to the Cursor returned with + # a previous query result if it was partial. + cursor: str = field(default=None) + # IncludeCursor will return the Cursor as part of the query result, if set + # to true. + includeCursor: bool = field(default=False) def raise_response_error(r): @@ -303,16 +310,8 @@ def _prepare_ingest_options(self, opts: Optional[IngestOptions]) -> Dict[str, An def _prepare_apl_options(self, opts: Optional[AplOptions]) -> Dict[str, Any]: """Prepare the apl query options for the request.""" - params = {} - - if opts is None: - params["format"] = AplResultFormat.Legacy.value - return params + params = {"format": AplResultFormat.Legacy.value} - if opts.no_cache: - params["nocache"] = opts.no_cache.__str__() - if opts.save: - params["save"] = opts.save if opts.format: params["format"] = opts.format.value @@ -330,5 +329,9 @@ def _prepare_apl_payload( params["startTime"] = opts.start_time if opts.end_time: params["endTime"] = opts.end_time + if opts.cursor: + params["cursor"] = opts.cursor + if opts.includeCursor: + params["includeCursor"] = opts.includeCursor return params diff --git a/tests/test_client.py b/tests/test_client.py index 385612c..7091d27 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -166,8 +166,6 @@ def test_step005_apl_query(self): opts = AplOptions( start_time=startTime, end_time=endTime, - no_cache=True, - save=False, format=AplResultFormat.Legacy, ) qr = self.client.query(apl, opts) From c614f6d397fed748426ad7a206411ba456af2143 Mon Sep 17 00:00:00 2001 From: Arne Bahlo Date: Fri, 6 Sep 2024 17:22:16 +0200 Subject: [PATCH 08/16] chore: Bump version to 0.5.0 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8c5c540..0ef6765 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "axiom-py" -version = "0.4.0" +version = "0.5.0" description = "Axiom API Python bindings." authors = ["Axiom, Inc."] license = "MIT" From c79eebfea8e1a462c9abd744c2f1d6b1ef0960ea Mon Sep 17 00:00:00 2001 From: Arne Bahlo Date: Fri, 6 Sep 2024 17:40:32 +0200 Subject: [PATCH 09/16] fix: Check if opts is None before using it --- axiom/client.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/axiom/client.py b/axiom/client.py index 6b1daca..b799980 100644 --- a/axiom/client.py +++ b/axiom/client.py @@ -312,8 +312,9 @@ def _prepare_apl_options(self, opts: Optional[AplOptions]) -> Dict[str, Any]: """Prepare the apl query options for the request.""" params = {"format": AplResultFormat.Legacy.value} - if opts.format: - params["format"] = opts.format.value + if opts is not None: + if opts.format: + params["format"] = opts.format.value return params From 553c01c43d8e28c9a33fa9b6328f367f72e8323b Mon Sep 17 00:00:00 2001 From: Arne Bahlo Date: Sat, 7 Sep 2024 10:11:26 +0200 Subject: [PATCH 10/16] fix: Make cursor Optional, improve checks --- axiom/client.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/axiom/client.py b/axiom/client.py index b799980..736742d 100644 --- a/axiom/client.py +++ b/axiom/client.py @@ -106,7 +106,7 @@ class AplOptions: format: AplResultFormat = field(default=AplResultFormat.Legacy) # Cursor is the query cursor. It should be set to the Cursor returned with # a previous query result if it was partial. - cursor: str = field(default=None) + cursor: Optional[str] = field(default=None) # IncludeCursor will return the Cursor as part of the query result, if set # to true. includeCursor: bool = field(default=False) @@ -326,11 +326,11 @@ def _prepare_apl_payload( params["apl"] = apl if opts is not None: - if opts.start_time: + if opts.start_time is not None: params["startTime"] = opts.start_time - if opts.end_time: + if opts.end_time is not None: params["endTime"] = opts.end_time - if opts.cursor: + if opts.cursor is not None: params["cursor"] = opts.cursor if opts.includeCursor: params["includeCursor"] = opts.includeCursor From 461a7d5267cf2011769532cfeada47de779b7c79 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 20 Feb 2024 02:43:25 +0000 Subject: [PATCH 11/16] Bump actions/setup-python from 4 to 5 Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d74559f..fb7de62 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} - run: pip install poetry==${{ env.POETRY_VERSION }} @@ -53,7 +53,7 @@ jobs: org_id: TESTING_STAGING_ORG_ID steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} - run: pip install poetry==${{ env.POETRY_VERSION }} @@ -72,7 +72,7 @@ jobs: - test-integration steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ env.PYTHON_VERSION }} - run: pip install poetry==${{ env.POETRY_VERSION }} From 6d9e5d58bf54501d50df986baa6d09c2d53cfee5 Mon Sep 17 00:00:00 2001 From: Arne Bahlo Date: Sat, 7 Sep 2024 10:37:31 +0200 Subject: [PATCH 12/16] chore: Run black on client.py --- axiom/client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/axiom/client.py b/axiom/client.py index 0d60c3b..90507e5 100644 --- a/axiom/client.py +++ b/axiom/client.py @@ -283,7 +283,9 @@ def _prepare_query_options(self, opts: QueryOptions) -> Dict[str, object]: return params - def _prepare_ingest_options(self, opts: Optional[IngestOptions]) -> Dict[str, object]: + def _prepare_ingest_options( + self, opts: Optional[IngestOptions] + ) -> Dict[str, object]: """the query params for ingest api are expected in a format that couldn't be defined as a variable name because it has a dash. As a work around, we create the params dict manually.""" From 1196706042bfd5da89e56d6ca80cef26db832531 Mon Sep 17 00:00:00 2001 From: William Ransohoff <5217539+WRansohoff@users.noreply.github.com> Date: Sun, 8 Sep 2024 15:11:11 -0400 Subject: [PATCH 13/16] Linting --- axiom/client.py | 9 +++------ axiom/tokens.py | 1 + tests/test_client.py | 6 ++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/axiom/client.py b/axiom/client.py index 054a540..5897aea 100644 --- a/axiom/client.py +++ b/axiom/client.py @@ -280,11 +280,8 @@ def query(self, apl: str, opts: Optional[AplOptions] = None) -> QueryResult: def create_api_token(self, opts: TokenAttributes) -> Token: """Creates a new API token with permissions specified in a TokenAttributes object.""" res = self.session.post( - '/v2/tokens', - data=ujson.dumps( - asdict(opts), - default=Util.handle_json_serialization - ) + "/v2/tokens", + data=ujson.dumps(asdict(opts), default=Util.handle_json_serialization), ) # Return the new token and ID. @@ -293,7 +290,7 @@ def create_api_token(self, opts: TokenAttributes) -> Token: def delete_api_token(self, token_id: str) -> None: """Delete an API token using its ID string.""" - self.session.delete(f'/v2/tokens/{token_id}') + self.session.delete(f"/v2/tokens/{token_id}") def _prepare_query_options(self, opts: QueryOptions) -> Dict[str, object]: """returns the query options as a Dict, handles any renaming for key fields.""" diff --git a/axiom/tokens.py b/axiom/tokens.py index 4ab8369..e10cc0a 100644 --- a/axiom/tokens.py +++ b/axiom/tokens.py @@ -81,5 +81,6 @@ class Token: Token contains the response from a call to POST /tokens. It includes the API token itself, and an ID which can be used to reference it later. """ + id: str token: str diff --git a/tests/test_client.py b/tests/test_client.py index 83049a8..42dfd96 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -23,7 +23,7 @@ WrongQueryKindException, DatasetCreateRequest, TokenAttributes, - TokenOrganizationCapabilities + TokenOrganizationCapabilities, ) from axiom.query import ( QueryLegacy, @@ -226,9 +226,7 @@ def test_api_tokens(self): """Test creating and deleting an API token""" token_attrs = TokenAttributes( name=f"PytestToken-{uuid.uuid4()}", - orgCapabilities=TokenOrganizationCapabilities( - apiTokens=["read"] - ) + orgCapabilities=TokenOrganizationCapabilities(apiTokens=["read"]), ) token_values = self.client.create_api_token(token_attrs) From eee0e09a7a3a1f14fb177858fad1dec09f1d9c48 Mon Sep 17 00:00:00 2001 From: William Ransohoff <5217539+WRansohoff@users.noreply.github.com> Date: Mon, 9 Sep 2024 17:08:01 -0400 Subject: [PATCH 14/16] Lint API token dataclass properties --- axiom/tokens.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/axiom/tokens.py b/axiom/tokens.py index e10cc0a..b289d60 100644 --- a/axiom/tokens.py +++ b/axiom/tokens.py @@ -1,5 +1,5 @@ -from dataclasses import dataclass -from typing import Literal +from dataclasses import dataclass, field +from typing import Literal, Optional @dataclass @@ -29,31 +29,31 @@ class TokenOrganizationCapabilities: """ # Ability to use annotations. Optional. - annotations: list[Literal["create", "read", "update", "delete"]] | None = None + annotations: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) # Ability to use api tokens. Optional. - apiTokens: list[Literal["create", "read", "update", "delete"]] | None = None + apiTokens: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) # Ability to access billing. Optional. - billing: list[Literal["read", "update"]] | None = None + billing: Optional[list[Literal["read", "update"]]] = field(default=None) # Ability to use dashboards. Optional. - dashboards: list[Literal["create", "read", "update", "delete"]] | None = None + dashboards: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) # Ability to use datasets. Optional. - datasets: list[Literal["create", "read", "update", "delete"]] | None = None + datasets: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) # Ability to use endpoints. Optional. - endpoints: list[Literal["create", "read", "update", "delete"]] | None = None + endpoints: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) # Ability to use flows. Optional. - flows: list[Literal["create", "read", "update", "delete"]] | None = None + flows: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) # Ability to use integrations. Optional. - integrations: list[Literal["create", "read", "update", "delete"]] | None = None + integrations: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) # Ability to use monitors. Optional. - monitors: list[Literal["create", "read", "update", "delete"]] | None = None + monitors: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) # Ability to use notifiers. Optional. - notifiers: list[Literal["create", "read", "update", "delete"]] | None = None + notifiers: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) # Ability to use role-based access controls. Optional. - rbac: list[Literal["create", "read", "update", "delete"]] | None = None + rbac: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) # Ability to use shared access keys. Optional. - sharedAccessKeys: list[Literal["read", "update"]] | None = None + sharedAccessKeys: Optional[list[Literal["read", "update"]]] = field(default=None) # Ability to use users. Optional. - users: list[Literal["create", "read", "update", "delete"]] | None = None + users: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) @dataclass @@ -66,13 +66,13 @@ class TokenAttributes: # Name for the token. Required. name: str # The token's dataset-level capabilities. Keyed on dataset name. Optional. - datasetCapabilities: dict[str, TokenDatasetCapabilities] | None = None + datasetCapabilities: Optional[dict[str, TokenDatasetCapabilities]] = field(default=None) # Description for the API token. Optional. - description: str | None = None + description: Optional[str] = field(default=None) # Expiration date for the API token. Optional. - expiresAt: str | None = None + expiresAt: Optional[str] = field(default=None) # The token's organization-level capabilities. Optional. - orgCapabilities: TokenOrganizationCapabilities | None = None + orgCapabilities: Optional[TokenOrganizationCapabilities] = field(default=None) @dataclass From abfa59c8bf4a3933f267c68b59cbee567f5a98da Mon Sep 17 00:00:00 2001 From: William Ransohoff <5217539+WRansohoff@users.noreply.github.com> Date: Mon, 9 Sep 2024 17:09:49 -0400 Subject: [PATCH 15/16] poetry black reformat --- axiom/tokens.py | 48 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/axiom/tokens.py b/axiom/tokens.py index b289d60..13b4b3f 100644 --- a/axiom/tokens.py +++ b/axiom/tokens.py @@ -29,31 +29,53 @@ class TokenOrganizationCapabilities: """ # Ability to use annotations. Optional. - annotations: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) + annotations: Optional[list[Literal["create", "read", "update", "delete"]]] = field( + default=None + ) # Ability to use api tokens. Optional. - apiTokens: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) + apiTokens: Optional[list[Literal["create", "read", "update", "delete"]]] = field( + default=None + ) # Ability to access billing. Optional. billing: Optional[list[Literal["read", "update"]]] = field(default=None) # Ability to use dashboards. Optional. - dashboards: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) + dashboards: Optional[list[Literal["create", "read", "update", "delete"]]] = field( + default=None + ) # Ability to use datasets. Optional. - datasets: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) + datasets: Optional[list[Literal["create", "read", "update", "delete"]]] = field( + default=None + ) # Ability to use endpoints. Optional. - endpoints: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) + endpoints: Optional[list[Literal["create", "read", "update", "delete"]]] = field( + default=None + ) # Ability to use flows. Optional. - flows: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) + flows: Optional[list[Literal["create", "read", "update", "delete"]]] = field( + default=None + ) # Ability to use integrations. Optional. - integrations: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) + integrations: Optional[list[Literal["create", "read", "update", "delete"]]] = field( + default=None + ) # Ability to use monitors. Optional. - monitors: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) + monitors: Optional[list[Literal["create", "read", "update", "delete"]]] = field( + default=None + ) # Ability to use notifiers. Optional. - notifiers: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) + notifiers: Optional[list[Literal["create", "read", "update", "delete"]]] = field( + default=None + ) # Ability to use role-based access controls. Optional. - rbac: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) + rbac: Optional[list[Literal["create", "read", "update", "delete"]]] = field( + default=None + ) # Ability to use shared access keys. Optional. sharedAccessKeys: Optional[list[Literal["read", "update"]]] = field(default=None) # Ability to use users. Optional. - users: Optional[list[Literal["create", "read", "update", "delete"]]] = field(default=None) + users: Optional[list[Literal["create", "read", "update", "delete"]]] = field( + default=None + ) @dataclass @@ -66,7 +88,9 @@ class TokenAttributes: # Name for the token. Required. name: str # The token's dataset-level capabilities. Keyed on dataset name. Optional. - datasetCapabilities: Optional[dict[str, TokenDatasetCapabilities]] = field(default=None) + datasetCapabilities: Optional[dict[str, TokenDatasetCapabilities]] = field( + default=None + ) # Description for the API token. Optional. description: Optional[str] = field(default=None) # Expiration date for the API token. Optional. From b7ed013ced6ee87ce23051d9005d8a9b4d6e676c Mon Sep 17 00:00:00 2001 From: William Ransohoff <5217539+WRansohoff@users.noreply.github.com> Date: Mon, 9 Sep 2024 17:15:32 -0400 Subject: [PATCH 16/16] More API token dataclass linting. --- axiom/tokens.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/axiom/tokens.py b/axiom/tokens.py index 13b4b3f..fc8fdf3 100644 --- a/axiom/tokens.py +++ b/axiom/tokens.py @@ -4,6 +4,7 @@ @dataclass class TokenDatasetCapabilities: + # pylint: disable=unsubscriptable-object """ TokenDatasetCapabilities describes the dataset-level permissions which a token can be assigned. @@ -12,17 +13,22 @@ class TokenDatasetCapabilities: """ # Ability to ingest data. Optional. - ingest: list[Literal["create"]] | None = None + ingest: Optional[list[Literal["create"]]] = field(default=None) # Ability to query data. Optional. - query: list[Literal["read"]] | None = None + query: Optional[list[Literal["read"]]] = field(default=None) # Ability to use starred queries. Optional. - starredQueries: list[Literal["create", "read", "update", "delete"]] | None = None + starredQueries: Optional[list[Literal["create", "read", "update", "delete"]]] = ( + field(default=None) + ) # Ability to use virtual fields. Optional. - virtualFields: list[Literal["create", "read", "update", "delete"]] | None = None + virtualFields: Optional[list[Literal["create", "read", "update", "delete"]]] = ( + field(default=None) + ) @dataclass class TokenOrganizationCapabilities: + # pylint: disable=unsubscriptable-object """ TokenOrganizationCapabilities describes the org-level permissions which a token can be assigned. @@ -80,6 +86,7 @@ class TokenOrganizationCapabilities: @dataclass class TokenAttributes: + # pylint: disable=unsubscriptable-object """ TokenAttributes describes the set of input parameters that the POST /tokens API accepts.