Skip to main content

CleanLibrary Python SDK — HttpVerdictClient + HttpRemediationClient + HttpEnrichClient triad (sister-shape with @cleanstart/cleanlib-sdk v0.4.4)

Project description

cleanlib-sdk

CleanLibrary Python SDK — asyncio + httpx; mirrors the Rust cleanlib-client HTTP surface.

Status: v0.4.3 — production-ready.

Install

pip install cleanlib-sdk

Usage

import asyncio
from cleanlib_sdk import Client, PolicyDenyError, RiskAcceptanceRequiredError

async def main() -> None:
    async with Client(
        endpoint="https://cleanapp.clnstrt.dev",
        api_key="clk_std_...",   # opaque CleanLibrary access key
    ) as c:
        try:
            v = await c.fetch_verdict("npm", "lodash", "4.17.21")
            print(f"{v.decision} composite_score={v.composite_score}")
            print(f"reasoning: {v.reasoning}")
        except PolicyDenyError as e:
            print(f"DENIED [{e.reason_code}]: {e.message}")
        except RiskAcceptanceRequiredError as e:
            print(f"RISK ACCEPT REQUIRED: {e.message}")
            if e.docs_url:
                print(f"see: {e.docs_url}")

asyncio.run(main())

Error hierarchy

All errors descend from CleanLibraryError. Subclasses:

Exception HTTP Triggered by
PolicyDenyError 403 / 451 POLICY_DENY_VERDICT / POLICY_DENY_RULE_EXPLICIT
IntegrityFailureError 403 INTEGRITY_FAILURE
RateLimitExceededError 429 tier-throttled; carries retry_after_seconds
RiskAcceptanceRequiredError 403 RISK_ACCEPTANCE_REQUIRED
AuthenticationError 401 / 403 KEY_INVALID / KEY_EXPIRED / KEY_SCOPE_INSUFFICIENT
InsufficientDataError 403 INSUFFICIENT_DATA_FAIL_CLOSED
PackageNotFoundError 404 not in catalog + ingest declined
ServerError 5xx retryable on 502/503/504
TransportError network / TLS / timeout / DNS
ParseError response body shape mismatch

Development

pip install -e ".[dev]"
pytest
ruff check .

Cross-references

License

Proprietary — CleanStart.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cleanlib_sdk-0.4.7.tar.gz (33.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cleanlib_sdk-0.4.7-py3-none-any.whl (43.4 kB view details)

Uploaded Python 3

File details

Details for the file cleanlib_sdk-0.4.7.tar.gz.

File metadata

  • Download URL: cleanlib_sdk-0.4.7.tar.gz
  • Upload date:
  • Size: 33.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for cleanlib_sdk-0.4.7.tar.gz
Algorithm Hash digest
SHA256 8c8d2413570e0ccc55f2b2f4c6ed18c5c53ef90f9842ce9f641f0896319fcc48
MD5 62ce805d9a3bab994c8acc0194eeda95
BLAKE2b-256 89e318d9ac87712dd2599756d9337d81eeb126a29633b9264a6b905ef5f2f4c6

See more details on using hashes here.

File details

Details for the file cleanlib_sdk-0.4.7-py3-none-any.whl.

File metadata

  • Download URL: cleanlib_sdk-0.4.7-py3-none-any.whl
  • Upload date:
  • Size: 43.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for cleanlib_sdk-0.4.7-py3-none-any.whl
Algorithm Hash digest
SHA256 430e65ae951a860315a83eb898dcbebd4f4b0022da9902bcce5338f87b40a504
MD5 720b27756d22fdd021b99d2eed6038b3
BLAKE2b-256 f5c3f352a1edc0280768bb6e25c82a87f5f01ae5b70f6dd8b6569e519d307148

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page