Skip to main content

CactusKIT SDK package

Project description

CactusKIT

Lightweight Python SDK for declaring small API handlers and producing consistent responses.

See package metadata in pyproject.toml.

Quick links

Overview

CactusKIT provides a single-purpose decorator cactuize to declare API entrypoints and a small response wrapper CactusResponse so handlers return consistent, serializable objects.

Key pieces:

  • cactuize(...) : decorator that validates/binds args, optionally enforces auth, and normalizes return values into CactusResponse.
  • CactusResponse / make_res() : response object and factory with helpers (size, hash, timestamp).
  • CactusEncoder : JSON encoder that can serialize CactusResponse instances.
  • Enums: HttpStatus, ApiProtocol, ApiMethod.

Installation

Install from source or PyPI when available:

pip install cactuskit

Usage

Import the symbols from the module and declare handlers with cactuize.

from cactuskit import ApiMethod, ApiProtocol, HttpStatus, cactuize

def authenticate():
    return True

@cactuize()
def simple_entrypoint():
    return f"Hello World from {simple_entrypoint}"

@cactuize(
    auth=authenticate,
    protocol=ApiProtocol.HTTP,
    method=ApiMethod.GET)
def entrypoint(name):
    return (HttpStatus.HTTP_CUSTOM(201), {
        "content": f"Hello {name}"
    })

Notes:

  • Handler functions may return a plain payload (dict or str) or a tuple (HttpStatus, payload).
  • If auth is provided to cactuize, it should be a callable returning truthy when authorized.

API Reference (short)

  • cactuize(protocol=ApiProtocol, method=ApiMethod, auth=None, middleware=None, args_mtable=None) : declare a function as a Cactus entrypoint. Performs argument binding and converts results into CactusResponse objects. When auth is provided, it is called and a failed check returns a plain "Authentication required" string.
  • CactusResponse(payload, status_code) : wrapper with helpers: get_payload(), get_status_code(), get_timestamp(), get_payload_size(), get_payload_hash().
  • make_res(payload, status_code=HttpStatus.HTTP_OK) : helper factory.
  • CactusEncoder : json.JSONEncoder subclass that serializes CactusResponse instances.

Development

  • Create a virtualenv and install dev dependencies (if any).
python -m venv .venv
source .venv/bin/activate
pip install -e .

Contributing

Contributions welcome. Open issues or pull requests and include tests for new behavior.

License

MIT : see LICENSE.

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

cactuskit-0.1.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

cactuskit-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file cactuskit-0.1.0.tar.gz.

File metadata

  • Download URL: cactuskit-0.1.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for cactuskit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8801db34f78d9738c747bc077d78b3e6b6632b85573e5eba4eed10201d2f758e
MD5 7e48464767d7a04795b0048dce80e52f
BLAKE2b-256 0cdb0da64ff4ad9ce82707109070a06aff553cf76a8951b3b5155af26fd9a4a6

See more details on using hashes here.

File details

Details for the file cactuskit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cactuskit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for cactuskit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c8d351213281c47460753b92bbcec258ea15fa2b5d818324fa0b49468060df7d
MD5 fb27eee85c089a1841cc7c1606631101
BLAKE2b-256 79cf0014a89b9507119acd0d78e7975f47f1a55b62ae1478c7866e10421bb0da

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