feat: add multi-region URL resolver and bump version to 1.6.0#76
Merged
Conversation
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
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ 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:
✅ BUILD PASSED - All security checks passed |
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ 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:
✅ BUILD PASSED - All security checks passed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Endpointclass for dynamic, region-aware URL resolution backed by a bundledregions.jsonregistryUtils.get_contentstack_endpoint()proxy so existingUtilsimport paths keep working without changescripts/refresh_regions.pyto pull the latest registry from Contentstack CDNProblem
Before this PR, the delivery host was either hardcoded (
cdn.contentstack.io) or manuallyconstructed 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 fromartifacts.contentstack.com) is the singlesource of truth.
Endpoint.get_contentstack_endpoint()resolves any region + servicecombination in O(n) lookup with zero HTTP calls at runtime.