Skip to content

Commit 1cc2bb3

Browse files
committed
Merge branch 'development' into enh/dx-7324
2 parents 456f627 + 2d11d26 commit 1cc2bb3

22 files changed

Lines changed: 905 additions & 221 deletions

File tree

.cursor/rules/README.md

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
1-
# Cursor Rules — Contentstack Python CDA SDK
1+
# Cursor (optional)
22

3-
This repository keeps **project guidance in [skills](../../skills/)** (one folder per topic, each with **`SKILL.md`**), not as separate rule files under `.cursor/rules/`.
3+
**Cursor** users: start at **[AGENTS.md](../../AGENTS.md)**. All conventions live in **`skills/*/SKILL.md`**.
44

5-
## Where to look
6-
7-
| Topic | Skill |
8-
|-------|--------|
9-
| PR checklist, public API, semver | [`skills/code-review/SKILL.md`](../../skills/code-review/SKILL.md) |
10-
| Branch, install, tests, versioning | [`skills/dev-workflow/SKILL.md`](../../skills/dev-workflow/SKILL.md) |
11-
| **Stack**, queries, CDA features | [`skills/contentstack-utils/SKILL.md`](../../skills/contentstack-utils/SKILL.md) |
12-
| **requests**, retries, **HTTPSConnection** | [`skills/framework/SKILL.md`](../../skills/framework/SKILL.md) |
13-
| Python layout and package conventions | [`skills/python-style/SKILL.md`](../../skills/python-style/SKILL.md) |
14-
| **pytest**, **`tests/`**, **`config.py`** | [`skills/testing/SKILL.md`](../../skills/testing/SKILL.md) |
15-
16-
**Index:** [`skills/README.md`](../../skills/README.md) · [`AGENTS.md`](../../AGENTS.md)
5+
This folder only points contributors to **`AGENTS.md`** so editor-specific config does not duplicate the canonical docs.

.github/workflows/issues-jira.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,4 @@ venv.bak/
118118
.mypy_cache/
119119
.idea/
120120
.vscode/
121+
*/assets/regions.json

AGENTS.md

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,50 @@
1-
# AGENTS.md — AI / automation context
1+
# Contentstack Python CDA SDK – Agent guide
22

3-
## Project
3+
**Universal entry point** for contributors and AI agents. Detailed conventions live in **`skills/*/SKILL.md`**.
44

5-
| | |
6-
|---|---|
7-
| **Name** | **Contentstack** (PyPI) — **Python Content Delivery SDK** |
8-
| **Purpose** | Python client for the **Content Delivery API (CDA)**: **Stack**, content types, entries, assets, queries, live preview, taxonomy, variants. Uses **`requests`** + **`urllib3.Retry`** via **`HTTPSConnection`**. |
9-
| **Repository** | [contentstack/contentstack-python](https://github.com/contentstack/contentstack-python.git) |
5+
## What this repo is
6+
7+
| Field | Detail |
8+
|--------|--------|
9+
| **Name:** | [contentstack/contentstack-python](https://github.com/contentstack/contentstack-python) |
10+
| **Purpose:** | Python client for the **Content Delivery API (CDA)**: stacks, content types, entries, assets, queries, live preview, taxonomy, and variants. Uses **`requests`** + **`urllib3.Retry`** via **`HTTPSConnection`**. |
11+
| **Out of scope:** | Content management (create / update / delete) — use `contentstack-management-python` for CMA operations. |
1012

11-
## Tech stack
13+
## Tech stack (at a glance)
1214

1315
| Area | Details |
1416
|------|---------|
15-
| **Language** | **Python** (see **`setup.py`** `python_requires`, classifiers) |
16-
| **HTTP** | **`requests`**, **`urllib3`** |
17-
| **Tests** | **pytest** + **`unittest.TestCase`** under **`tests/`** |
18-
| **Packaging** | **`setuptools`** / **`setup.py`**, package **`contentstack`** |
17+
| Language | Python ≥ 3.6 (`setup.py` `python_requires`) |
18+
| Build | `setuptools` / `setup.py`; package `contentstack` |
19+
| Tests | `pytest``tests/test_*.py`; config in `tests/pytest.ini` |
20+
| Lint / coverage | `ruff`, `flake8`, `black`, `isort`; `pytest-cov` for coverage |
21+
| HTTP | `requests`, `urllib3` |
1922

20-
## Source layout
23+
## Commands (quick reference)
2124

22-
| Path | Role |
23-
|------|------|
24-
| `contentstack/stack.py` | **`Stack`**, **`ContentstackRegion`**, endpoint and **HTTPSConnection** wiring |
25-
| `contentstack/https_connection.py`, `contentstack/controller.py` | Session, retries, **`get_request`** |
26-
| `contentstack/query.py`, `contentstack/basequery.py` | Queries |
27-
| `contentstack/entry.py`, `asset.py`, `contenttype.py`, … | Domain modules |
28-
| `contentstack/__init__.py` | Public exports (**`Stack`**, **`Entry`**, **`Asset`**, …), **`__version__`** |
29-
| `config.py` (repo root) | Test credentials and UIDs — **must not commit secrets** |
30-
| `tests/*.py` | Integration-style tests importing **`config`** |
31-
32-
## Common commands
25+
| Command Type | Command |
26+
|---|---|
27+
| Build | `pip install -e .` |
28+
| Install deps | `pip install -r requirements.txt` |
29+
| Test | `pytest tests/` |
30+
| Coverage | `pytest --cov=contentstack tests/` |
31+
| Lint | `ruff check contentstack/` |
3332

34-
```bash
35-
pip install -r requirements.txt
36-
pip install -e .
37-
pytest tests/
38-
```
33+
CI: [`.github/workflows/python-publish.yml`](.github/workflows/python-publish.yml) · [`.github/workflows/check-branch.yml`](.github/workflows/check-branch.yml)
3934

40-
## Environment / test configuration
35+
## Where the documentation lives: skills
4136

42-
Tests load stack settings from root **`config.py`** (e.g. **HOST**, **APIKEY**, **DELIVERYTOKEN**, **ENVIRONMENT**). Use a local, gitignored file or sanitized values for CI. Do not commit secrets.
37+
| Skill | Path | What it covers |
38+
|---|---|---|
39+
| Development workflow | [`skills/dev-workflow/SKILL.md`](skills/dev-workflow/SKILL.md) | Install, tests, `config.py`, versioning, PR baseline |
40+
| Contentstack CDA SDK | [`skills/contentstack-utils/SKILL.md`](skills/contentstack-utils/SKILL.md) | `Stack`, queries, entries, assets, live preview, taxonomy, HTTP session |
41+
| Python style & repo layout | [`skills/python-style/SKILL.md`](skills/python-style/SKILL.md) | Package layout, `setup.py`, naming conventions, no secret logging |
42+
| Testing | [`skills/testing/SKILL.md`](skills/testing/SKILL.md) | `pytest`, `tests/`, `config.py`, credential hygiene |
43+
| Code review | [`skills/code-review/SKILL.md`](skills/code-review/SKILL.md) | PR checklist, public API, `Stack`, HTTP layer, secrets |
44+
| Framework / HTTP | [`skills/framework/SKILL.md`](skills/framework/SKILL.md) | `requests`, `HTTPSConnection`, `urllib3` retries, timeouts |
4345

44-
## Further guidance
46+
An index with "when to use" hints is in [`skills/README.md`](skills/README.md).
4547

46-
- **Cursor rules:** [`.cursor/rules/README.md`](.cursor/rules/README.md)
47-
- **Skills:** [`skills/README.md`](skills/README.md)
48+
## Using Cursor (optional)
4849

49-
Product docs: [Content Delivery API](https://www.contentstack.com/docs/developers/apis/content-delivery-api/).
50+
If you use **Cursor**, [`.cursor/rules/README.md`](.cursor/rules/README.md) only points to **`AGENTS.md`**—same docs as everyone else.

CHANGELOG.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
11
# CHANGELOG
22

3-
## _v2.6.0_
3+
## _v2.7.0_
44

5-
### **Date: 18-May-2026**
5+
### **Date: 20-July-2026**
66

77
- Added optional branch support for entry variants on `Entry.variants()` and `ContentType.variants()`.
88

9+
## _v2.6.1_
10+
11+
### **Date: 13-July-2026**
12+
13+
- Removed unused `keyring` dependency to resolve a Snyk license-policy issue on the transitive `secretstorage` package.(Snyk Fix)
14+
15+
## _v2.6.0_
16+
17+
### **Date: 22-June-2026**
18+
19+
- Dynamic endpoint resolution via new `Endpoint` class.
20+
- Region-to-URL mapping is now loaded from a bundled `regions.json` (sourced from `artifacts.contentstack.com`) instead of hardcoded `if/elif` chains.
21+
- Added `Endpoint.get_contentstack_endpoint(region, service, omit_https)` — resolves any supported region to its `contentDelivery`, `contentManagement`, or other service URL.
22+
- Added `contentstack.get_contentstack_endpoint()` module-level proxy.
23+
- `Stack` now auto-resolves `host` and `live_preview` management host via `Endpoint` on initialization.
24+
- Bundled `contentstack/assets/regions.json` included in `package_data` — always present after `pip install`.
25+
- `setup.py` auto-refreshes `regions.json` at build time via a custom `BuildPyWithRegions` command; network failures warn but never block the build.
26+
- Runtime fallback: if `regions.json` is absent, the SDK downloads it live on the first `Endpoint` call.
27+
- Added `refresh_regions()` utility to programmatically download the latest regions manifest from the Contentstack CDN and overwrite the bundled `assets/regions.json` (`from contentstack import refresh_regions`).
28+
- Added `python3 -m contentstack.region_refresh` CLI command for refreshing the registry after `pip install` (source-tree script `scripts/download_regions.py` is for contributors only).
29+
930
## _v2.5.1_
1031

1132
### **Date: 15-April-2026**

contentstack/__init__.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,43 @@
66
from .entry import Entry
77
from .asset import Asset
88
from .contenttype import ContentType
9+
from .endpoint import Endpoint
910
from .https_connection import HTTPSConnection
1011
from contentstack.stack import Stack
1112
from .utility import Utils
13+
from .region_refresh import refresh_regions
1214

1315
__all__ = (
1416
"Entry",
1517
"Asset",
1618
"ContentType",
19+
"Endpoint",
1720
"HTTPSConnection",
1821
"Stack",
19-
"Utils"
22+
"Utils",
23+
"refresh_regions",
2024
)
2125

26+
27+
def get_contentstack_endpoint(region='us', service='', omit_https=False):
28+
"""
29+
Resolve a Contentstack service endpoint URL for a given region.
30+
31+
Proxy to :class:`Endpoint.get_contentstack_endpoint` for convenience —
32+
mirrors ``Contentstack::getContentstackEndpoint()`` in the PHP SDK.
33+
34+
:param region: Region ID or alias ('us', 'eu', 'azure-na', 'gcp-eu', ...).
35+
:param service: Service key ('contentDelivery', 'contentManagement', ...).
36+
When empty, returns a dict of all endpoints for the region.
37+
:param omit_https: When True, strips 'https://' from the returned URL(s).
38+
:returns: str when service is provided, dict[str,str] otherwise.
39+
"""
40+
return Endpoint.get_contentstack_endpoint(region, service, omit_https)
41+
2242
__title__ = 'contentstack-delivery-python'
2343
__author__ = 'contentstack'
2444
__status__ = 'debug'
25-
__version__ = 'v2.6.0'
45+
__version__ = 'v2.7.0'
2646
__endpoint__ = 'cdn.contentstack.io'
2747
__email__ = 'support@contentstack.com'
2848
__developer_email__ = 'mobile@contentstack.com'

contentstack/contenttype.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
# ************* Module ContentType **************
99
# Your code has been rated at 10.00/10 by pylint
10+
from __future__ import annotations
1011
import json
1112
import logging
1213
from urllib import parse

0 commit comments

Comments
 (0)