Add base API clients, serde utilities, and auth improvements#48
Merged
Michel Edkrantz (MichelEdkrantz) merged 21 commits intomasterfrom Feb 13, 2026
Merged
Add base API clients, serde utilities, and auth improvements#48Michel Edkrantz (MichelEdkrantz) merged 21 commits intomasterfrom
Michel Edkrantz (MichelEdkrantz) merged 21 commits intomasterfrom
Conversation
Move Base API Clients from kognic-base-api-client-python into kognic-auth-python: - BaseApiClient (sync, requests-based) with lazy session initialization - BaseAsyncApiClient (async, httpx-based) extending HttpxAuthAsyncClient Features: - OAuth2 authentication with automatic token refresh - Automatic JSON serialization for jsonable objects - Retry logic for transient errors (502, 503, 504) - Sunset header handling (logs warnings for deprecated endpoints) - Enhanced error messages with response body details Also adds: - _protocols.py: Protocol definitions for duck typing - _serde.py: Serialization/deserialization utilities - _sunset.py: Sunset header handling - _user_agent.py: User-Agent string construction Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add recursive serialization for nested objects in containers - Rename serialize_to_json to to_json for consistency - to_json takes precedence over to_dict - Split test_serde.py into test_serialization.py and test_deserialization.py - Rename _serde.py to serde.py (public module) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add model_dump/model_validate support for Pydantic v2 models - Add robust type checking using MutableSequence/MutableMapping - Add pydantic>=2 to dev dependencies - Fix Python 3.9 compatibility (use Optional[str] instead of str | None) - Add test_serde_pydantic.py with 11 Pydantic tests - Add test_type_helpers.py with 12 type helper tests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Document serialize_body() and deserialize() with examples for: - Pydantic models - Custom classes with to_dict()/from_dict() - Nested objects in containers - Envelope extraction Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Use astral-sh/setup-uv@v5 action with caching - Use uv python install for Python version - Use uv sync --all-extras for dependencies - Use uv run pytest for testing Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix sunset date parsing to use UTC-aware datetimes - Support sunset dates without microseconds - Add comprehensive credentials_parser tests - Forward **kwargs to httpx client in BaseAsyncApiClient - Document json_serializer in create_session docstring - Fix ruff target-version to match requires-python (py39) - Remove legacy ANNOTELL env var fallbacks Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2a088da to
0fb659a
Compare
…ts, param order - Remove unused `PathLike` import from httpx/base_client.py - Align `_update_token` parameter order (access_token, refresh_token) in async client - Add path validation (reject leading `/`) to async base client matching sync - Normalize docstrings from `:param` to `Args:` style across auth sessions - Remove redundant explicit `Accept-Encoding: gzip` header from sync client - Run ruff fix + format Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ntext) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…/default_environment Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds os.PathLike to type hints for auth, env_config_path, and path parameters across credentials_parser, env_config, and both base clients. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a WARNING-level handler on kognic.auth logger so sunset deprecation warnings and rate limit errors are visible in CLI output. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BaseApiClient(sync, requests-based) andBaseAsyncApiClient(async, httpx-based) for building authenticated HTTP clientsserialize_body,deserialize) with Pydantic v2 supportjson_serializerparameter to base clients for overriding request body serialization/) to both sync and async base clientsasync with) toBaseAsyncApiClient**kwargsto underlying httpx client inBaseAsyncApiClientcontexts/default_contexttoenvironments/default_environment--configflag to--env-config-file-pathDEFAULT_CONFIG_PATHtoDEFAULT_ENV_CONFIG_FILE_PATHconfig.pytoenv_config.py_update_tokenparameter order, docstring style (Args:), path validationPathLikeimport, redundantAccept-Encoding: gzipheader, duplicate importsANNOTELL_*env var fallbacks from credentials parseruvfor CI instead of pipTest plan
🤖 Generated with Claude Code