Skip to content

Latest commit

History

History
86 lines (65 loc) · 5.62 KB

File metadata and controls

86 lines (65 loc) · 5.62 KB

Contentstack Management Python – Agent guide

Universal entry point for contributors and AI agents. Detailed conventions live in skills/*/SKILL.md.

What this repo is

FieldDetail
Name:contentstack-management (PyPI) — contentstack/contentstack-management-python
Purpose:Python client for the Content Management API (CMA): organizations, stacks, content types, entries, assets, webhooks, workflows, OAuth, and related resources. Uses requests via _APIClient.

Tech stack (at a glance)

AreaDetails
LanguagePython ≥ 3.9 (setup.pypython_requires)
Buildsetuptools / setup.py; package contentstack_management
HTTPrequests, requests-toolbelt, urllib3
Testspytesttests/integration (live e2e / sanity, dynamic stack), tests/unit, tests/mock, tests/api (legacy, superseded by tests/integration)
Lint / coveragepylint, coverage (see requirements-dev.txt)
Secrets / hooksTalisman, Snyk (see README.md development setup)

Source layout

PathRole
contentstack_management/contentstack.pyClient, Region, endpoint construction, user_agents, optional OAuth wiring
contentstack_management/_api_client.py_APIClient — HTTP calls, retries, optional OAuth interceptor
contentstack_management/stack/stack.pyStack-scoped CMA operations
contentstack_management/*/Domain modules (entries, assets, webhooks, taxonomies, …)
contentstack_management/__init__.pyPublic exports
tests/integration/Live e2e / sanity suite (pytest). Self-contained: creates a fresh stack per run, exercises every SDK method (positive/negative/edge), tears it down. Own framework/ + data/; config in tests/integration/.env.
tests/cred.pyget_credentials()dotenv + env vars for the legacy tests/api / tests/mock suites

Commands (quick reference)

Command TypeCommand
Installpip install -e ".[dev]"
Sanity / e2e (live)pytest tests/integration — dynamically creates a stack, runs the full suite, tears it down. Needs tests/integration/.env (EMAIL, PASSWORD, HOST, ORGANIZATION). Writes a timestamped HTML report + cURL log to the repo root.
Sanity, keep stackDELETE_DYNAMIC_RESOURCES=false pytest tests/integration (preserve the created stack for debugging)
Sanity, one resourcepytest tests/integration/api/test_12_content_type.py
Test (unit)pytest tests/unit/ -v
Test (mock)pytest tests/mock/ -v
Test (legacy API, live)pytest tests/api/ -v (needs .env — see tests/cred.py)
Coverage (CI)coverage run -m pytest tests/unit/
Lintpylint contentstack_management/

CI note:.github/workflows/unit-test.yml runs only tests/unit/ (no credentials). The tests/integration sanity suite is run manually (or via a credential-gated job) because it provisions real stacks.

Environment variables

Sanity / e2e suite (tests/integration) — configured via tests/integration/.env (gitignored). No pre-existing stack/UIDs needed; the suite creates everything at runtime.

VarRequiredPurpose
EMAIL, PASSWORDLogin for the run (a non-2FA account)
HOSTAPI host (e.g. api.contentstack.io)
ORGANIZATIONOrg the dynamic test stack is created in
MFA_SECRETTOTP secret (for the OAuth/2FA account, not the primary login)
DELETE_DYNAMIC_RESOURCESfalse keeps the created stack for debugging (default deletes)
CLIENT_ID, APP_ID, REDIRECT_URIOAuth tests
PERSONALIZE_HOSTPersonalize project for variant tests

Legacy tests/api / tests/mock — loaded via tests/cred.py (load_dotenv()): HOST, APIKEY, AUTHTOKEN, MANAGEMENT_TOKEN, ORG_UID, and resource UIDs. See that file for the full list.

Do not commit secrets. tests/integration/.env, docs/, and the repo-root cma-python-report-*.html / api-requests-*.txt are gitignored.

Where the documentation lives: skills

SkillPathWhat it covers
Development workflowskills/dev-workflow/SKILL.mdInstall, pytest suites, packaging version, pylint, hooks, PR baseline
Contentstack Management (SDK)skills/contentstack-management/SKILL.mdClient, Stack, _APIClient, CMA resources, OAuth, CMA docs
Python style & repo layoutskills/python-style/SKILL.mdPackage layout, naming, imports via _APIClient, secrets in logs
Testingskills/testing/SKILL.mdpytest unit / API / mock, tests/cred.py, env hygiene
Code reviewskills/code-review/SKILL.mdPR checklist—public API, HTTP/auth, tests, security
Framework / HTTPskills/framework/SKILL.mdrequests, retries, OAuth interceptor, where to change transport

An index with “when to use” hints is in skills/README.md.

Using Cursor (optional)

If you use Cursor, .cursor/rules/README.md only points to AGENTS.md—same docs as everyone else.

Product docs: Content Management API.