Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
## Content Management SDK For Python
---

## v1.1.0

#### Date: 14 May 2024

- Added GCP NA region support
---

## v1.0.1

#### Date: 12 December 2023
Expand Down
2 changes: 1 addition & 1 deletion contentstack_management/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
__author__ = 'ishaileshmishra'
__status__ = 'debug'
__region__ = 'na'
__version__ = '1.0.1'
__version__ = '1.1.0'
__host__ = 'api.contentstack.io'
__protocol__ = 'https://'
__api_version__ = 'v3'
Expand Down
4 changes: 4 additions & 0 deletions contentstack_management/contentstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class Region(Enum):
EU = "eu"
AZURE_EU = "azure-eu"
AZURE_NA = "azure-na"
GCP_NA = "gcp-na"


def user_agents(headers=None):
Expand All @@ -35,6 +36,9 @@ def __init__(self, host: str = 'api.contentstack.io', scheme: str = 'https://',
self.endpoint = 'https://api.contentstack.io/v3/'
if region is not None and host is not None and region is not Region.US.value:
self.endpoint = f'{scheme}{region}-{host}/{version}/'
if region is not None and host is None and region is not Region.US.value:
host = 'api.contentstack.com'
self.endpoint = f'{scheme}{region}-{host}/{version}/'
if host is not None and region is None:
self.endpoint = f'{scheme}{host}/{version}/'
if headers is None:
Expand Down
4 changes: 4 additions & 0 deletions tests/test_contentstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ def test_client(self):
client = contentstack_management.Client(authtoken='your_authtoken')
self.assertEqual('https://api.contentstack.io/v3/', client.endpoint) # Default host 'api.contentstack.io'

def test_gcp_na_region(self):
client = contentstack_management.Client(authtoken='your_authtoken', region='gcp-na')
self.assertEqual('https://gcp-na-api.contentstack.com/v3/', client.endpoint)

def test_successful_get_login(self):
client = contentstack_management.Client(host=host)
response = client.login(username, password)
Expand Down