Skip to content

feat: add multi-region URL resolver and bump version to 1.6.0#76

Merged
OMpawar-21 merged 2 commits into
developmentfrom
DX-7281
Jun 5, 2026
Merged

feat: add multi-region URL resolver and bump version to 1.6.0#76
OMpawar-21 merged 2 commits into
developmentfrom
DX-7281

Conversation

@OMpawar-21

Copy link
Copy Markdown

Summary

  • Adds Endpoint class for dynamic, region-aware URL resolution backed by a bundled regions.json registry
  • Adds Utils.get_contentstack_endpoint() proxy so existing Utils import paths keep working without change
  • Adds scripts/refresh_regions.py to pull the latest registry from Contentstack CDN
  • Adds 53 tests covering all regions, aliases, services, error cases, and cache behaviour
  • Bumps version to 1.6.0

Problem

Before this PR, the delivery host was either hardcoded (cdn.contentstack.io) or manually
constructed per region with string concatenation. There was no single authoritative source
for which URL maps to which region and service across the Python SDK.

Solution

A bundled regions.json (fetched live from artifacts.contentstack.com) is the single
source of truth. Endpoint.get_contentstack_endpoint() resolves any region + service
combination in O(n) lookup with zero HTTP calls at runtime.

from contentstack_utils import Endpoint

# Full URL
Endpoint.get_contentstack_endpoint("na", "contentDelivery")
# → "https://cdn.contentstack.io"

# Host only — pass directly to delivery SDK
host = Endpoint.get_contentstack_endpoint("eu", "contentDelivery", omit_https=True)
# → "eu-cdn.contentstack.com"
stack = contentstack.Stack(api_key, token, env, host=host)

# All endpoints for a region
Endpoint.get_contentstack_endpoint("azure-na")
# → {"contentDelivery": "...", "contentManagement": "...", ...18 keys}

Introduce contentstack_utils.Endpoint — a region-aware endpoint resolver
backed by a bundled regions.json registry, bringing the Python SDK to
feature parity with the PHP and JS implementations.

New files:
- contentstack_utils/endpoint.py: Endpoint class with in-process cache,
  two-pass region lookup (id → alias), case-insensitive matching with
  - / _ interchangeability, omit_https flag, and a CDN fallback download
  when regions.json is absent
- contentstack_utils/assets/regions.json: bundled registry of 7 regions
  (AWS NA/EU/AU, Azure NA/EU, GCP NA/EU) and 18 service endpoint keys;
  gitignored so it is not tracked as source — refreshed via refresh script
- tests/test_endpoint.py: 53 tests covering all 7 regions, 8 NA aliases,
  omit_https, error cases, Utils proxy, camelCase alias, and cache isolation
- scripts/refresh_regions.py: pulls latest regions.json from
  artifacts.contentstack.com (equivalent of composer refresh-regions)

Modified files:
- contentstack_utils/utils.py: add get_contentstack_endpoint() proxy and
  getContentstackEndpoint camelCase alias on Utils for cross-SDK parity
- contentstack_utils/__init__.py: export Endpoint in __all__;
  bump __version__ to 1.6.0
- setup.py: bump version to 1.6.0
- CHANGELOG.md: add v1.6.0 entry
- .gitignore: exclude contentstack_utils/assets/regions.json
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 1 25 ✅ Passed
🟡 Medium Severity 0 3 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

ℹ️ Vulnerabilities Without Available Fixes (Informational Only)

The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:

  • Critical without fixes: 0
  • High without fixes: 1
  • Medium without fixes: 3
  • Low without fixes: 0

✅ BUILD PASSED - All security checks passed

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

🔒 Security Scan Results

ℹ️ Note: Only vulnerabilities with available fixes (upgrades or patches) are counted toward thresholds.

Check Type Count (with fixes) Without fixes Threshold Result
🔴 Critical Severity 0 0 10 ✅ Passed
🟠 High Severity 0 1 25 ✅ Passed
🟡 Medium Severity 0 3 500 ✅ Passed
🔵 Low Severity 0 0 1000 ✅ Passed

⏱️ SLA Breach Summary

✅ No SLA breaches detected. All vulnerabilities are within acceptable time thresholds.

Severity Breaches (with fixes) Breaches (no fixes) SLA Threshold (with/no fixes) Status
🔴 Critical 0 0 15 / 30 days ✅ Passed
🟠 High 0 0 30 / 120 days ✅ Passed
🟡 Medium 0 0 90 / 365 days ✅ Passed
🔵 Low 0 0 180 / 365 days ✅ Passed

ℹ️ Vulnerabilities Without Available Fixes (Informational Only)

The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:

  • Critical without fixes: 0
  • High without fixes: 1
  • Medium without fixes: 3
  • Low without fixes: 0

✅ BUILD PASSED - All security checks passed

@sunil-lakshman sunil-lakshman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@OMpawar-21 OMpawar-21 marked this pull request as ready for review June 5, 2026 10:03
@OMpawar-21 OMpawar-21 requested a review from a team as a code owner June 5, 2026 10:03
@OMpawar-21 OMpawar-21 merged commit 28f09df into development Jun 5, 2026
9 checks passed
@OMpawar-21 OMpawar-21 deleted the DX-7281 branch June 5, 2026 10:03
@OMpawar-21 OMpawar-21 restored the DX-7281 branch June 9, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants