A Python SDK to connect to the CTI Clarity API server.
Project description
Clarity API SDK for Python
A Python SDK for connecting to the CTI API server, with structured logging included.
Installation
pip install clarity-api-sdk-python
Logging
Logging support is built with structlog.
Set the root logger by setting the environment variable LOG_LEVEL. Otherwise, the default root logging is set to INFO.
"""Example"""
import logging
from cti.logger import initialize_logger, get_logger, ExternalLoggerConfig
initialize_logger(
external_logger_configurations=[
ExternalLoggerConfig(name="urllib3"),
ExternalLoggerConfig(name="httpcore"),
ExternalLoggerConfig(name="httpx"),
ExternalLoggerConfig(name="httpx_auth"),
ExternalLoggerConfig(name="httpx_retries"),
],
handlers=[logging.FileHandler("app.log")]
)
logger_a = get_logger("logger_a")
logger_b = get_logger("logger_b", "WARNING")
# root_logger = logging.getLogger()
# root_logger.setLevel("DEBUG")
logger_a.info("This is info message from logger_a")
logger_a.critical("This is critical message from logger_a")
# Dynamically change the log level of logger_a to WARNING
print("\nChanging logger_a level to WARNING...\n")
logging.getLogger("logger_a").setLevel(logging.WARNING)
logger_a.info("This info message from logger_a should NOT be visible.")
logger_a.warning("This is a new warning message from logger_a.")
logger_b.info("This info message from logger_b should NOT be visible.")
logger_b.warning("This is warning message from logger_b")
# the value will be redacted
logger_b.info("password", extra={"aws_access_key_id", "AKIAIOSFODNN7EXAMPLE"})
Model
Pydantic models.
API
Singleton async client
import asyncio
from cti.api.session import initialize_async_client, close_async_client
async def main():
await initialize_async_client()
# ... your application logic ...
await close_async_client()
if __name__ == "__main__":
asyncio.run(main())
# In other modules
from cti.api.session import get_async_client
async def fetch_data():
client = get_async_client()
response = await client.get(...)
return response.json()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clarity_api_sdk_python-0.4.1.tar.gz.
File metadata
- Download URL: clarity_api_sdk_python-0.4.1.tar.gz
- Upload date:
- Size: 54.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3ab9196325349662e21929a1fd0f6313e9bae28271bc8258dcec321af361cc9
|
|
| MD5 |
db324587d9c61665ec0f995332d00dc8
|
|
| BLAKE2b-256 |
a54460d2f24f7c0c16477be32e59efa407d54616391230175be54a8b523c7788
|
Provenance
The following attestation bundles were made for clarity_api_sdk_python-0.4.1.tar.gz:
Publisher:
publish.yml on chesapeake-tech/clarity-api-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clarity_api_sdk_python-0.4.1.tar.gz -
Subject digest:
f3ab9196325349662e21929a1fd0f6313e9bae28271bc8258dcec321af361cc9 - Sigstore transparency entry: 1398021836
- Sigstore integration time:
-
Permalink:
chesapeake-tech/clarity-api-sdk-python@7843ea18a89b97d558e650942e4da905d2039003 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/chesapeake-tech
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7843ea18a89b97d558e650942e4da905d2039003 -
Trigger Event:
release
-
Statement type:
File details
Details for the file clarity_api_sdk_python-0.4.1-py3-none-any.whl.
File metadata
- Download URL: clarity_api_sdk_python-0.4.1-py3-none-any.whl
- Upload date:
- Size: 62.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52123681e29d7ae30afe2252d9640c307697a5797ec8cd888085f2046079956b
|
|
| MD5 |
761668e8a8c8fcdeed546545aa63214d
|
|
| BLAKE2b-256 |
d48bf63abafa2e832d0e04fdad120f9a80edd48fb89702414db3da3f95057bb3
|
Provenance
The following attestation bundles were made for clarity_api_sdk_python-0.4.1-py3-none-any.whl:
Publisher:
publish.yml on chesapeake-tech/clarity-api-sdk-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clarity_api_sdk_python-0.4.1-py3-none-any.whl -
Subject digest:
52123681e29d7ae30afe2252d9640c307697a5797ec8cd888085f2046079956b - Sigstore transparency entry: 1398021927
- Sigstore integration time:
-
Permalink:
chesapeake-tech/clarity-api-sdk-python@7843ea18a89b97d558e650942e4da905d2039003 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/chesapeake-tech
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7843ea18a89b97d558e650942e4da905d2039003 -
Trigger Event:
release
-
Statement type: