From 6f40d3a9ca09e935f7e13670d8a7a874156d4555 Mon Sep 17 00:00:00 2001 From: sunil-lakshman <104969541+sunil-lakshman@users.noreply.github.com> Date: Thu, 29 Aug 2024 11:54:19 +0530 Subject: [PATCH 1/2] Added early access support --- CHANGELOG.md | 6 ++++++ contentstack_management/__init__.py | 2 +- contentstack_management/contentstack.py | 6 +++++- tests/test_contentstack.py | 5 ++++- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e73bfe..86e3545 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ ## Content Management SDK For Python --- +## v1.3.0 + +#### Date: 04 September 2024 + +- Added Early access support. +--- ## v1.2.0 diff --git a/contentstack_management/__init__.py b/contentstack_management/__init__.py index f9d9200..c98a314 100644 --- a/contentstack_management/__init__.py +++ b/contentstack_management/__init__.py @@ -72,7 +72,7 @@ __author__ = 'ishaileshmishra' __status__ = 'debug' __region__ = 'na' -__version__ = '1.2.0' +__version__ = '1.3.0' __host__ = 'api.contentstack.io' __protocol__ = 'https://' __api_version__ = 'v3' diff --git a/contentstack_management/contentstack.py b/contentstack_management/contentstack.py index 0c440a5..f839067 100644 --- a/contentstack_management/contentstack.py +++ b/contentstack_management/contentstack.py @@ -31,7 +31,7 @@ class Client: # TODO: DefaultCSCredential(), needs to be implemented def __init__(self, host: str = 'api.contentstack.io', scheme: str = 'https://', authtoken: str = None , management_token=None, headers: dict = None, - region: Region = Region.US.value, version='v3', timeout=2, max_retries: int = 18, + region: Region = Region.US.value, version='v3', timeout=2, max_retries: int = 18, early_access: list = None, **kwargs): self.endpoint = 'https://api.contentstack.io/v3/' if region is not None and host is not None and region is not Region.US.value: @@ -43,6 +43,10 @@ def __init__(self, host: str = 'api.contentstack.io', scheme: str = 'https://', self.endpoint = f'{scheme}{host}/{version}/' if headers is None: headers = {} + if early_access is not None: + early_access_str = ', '.join(self.early_access) + headers['x-header-ea'] = early_access_str + if authtoken is not None: headers['authtoken'] = authtoken diff --git a/tests/test_contentstack.py b/tests/test_contentstack.py index 9168e78..ebd911a 100644 --- a/tests/test_contentstack.py +++ b/tests/test_contentstack.py @@ -50,7 +50,10 @@ def test_error_password(self): self.assertEqual( "'You are not permitted to the stack without valid password'", e.args[0]) - + def test_earlyaccess(self): + client = contentstack_management.Client(host=host, early_access=['ea1','ea2']) + response = client.login(username, password) + self.assertEqual(response.request.headers["x-header-ea"], "ea1, ea2") if __name__ == '__main__': From 374d7551367992129c5da785dc8e7197033144c5 Mon Sep 17 00:00:00 2001 From: sunil-lakshman <104969541+sunil-lakshman@users.noreply.github.com> Date: Thu, 29 Aug 2024 12:02:51 +0530 Subject: [PATCH 2/2] Package bump --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e825041..f1244b4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ python-dotenv~=1.0.0 -setuptools==68.0.0 +setuptools==70.0.0 requests~=2.32.0 pylint bson>=0.5.9