Skip to content

DX | 09-06-2025 | Release #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
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
16 changes: 15 additions & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -354,4 +354,18 @@ fileignoreconfig:
checksum: c7323b95249759bc67c33d3a89d3d2e8b3ed3d146b944682d451ebebe22567c0
- filename: .github/workflows/secrets-scan.yml
checksum: d79ec3f3288964f7d117b9ad319a54c0ebc152e35f69be8fde95522034fdfb2a
version: ""
- filename: tests/api/global_fields/test_global_fields_api.py
checksum: 1cd57383fcad33cfaddc03aec9a7ee3e85b27de35e4545462fca33e74768e812
- filename: tests/unit/global_fields/test_global_fields_unittest.py
checksum: 9bb05624cf1dadb770b3cf17fbfe915cf3133d622110da30a7dfebdeab0a315c
- filename: tests/api/global_fields/test_global_fields_api.py
checksum: ef69455a51168ea34d62a68caea0984504d3feeafb78010947fa99d7c54d9e9c
- filename: tests/unit/bulk_operations/test_bulk_releases_unit.py
checksum: 6f21d8928139fe511b7477d25276c3d73d0f500d5b489ac69939f34f5ae6cad9
- filename: tests/api/global_fields/test_global_fields_api.py
checksum: ef69455a51168ea34d62a68caea0984504d3feeafb78010947fa99d7c54d9e9c
- filename: tests/unit/release_items/test_release_items_unit.py
checksum: f92e78bc9aa8fcdf4cf8490eaa81c7ce8ce518767d9becf1393e847cc2ee12c4
- filename: tests/unit/global_fields/test_global_fields_unittest.py
checksum: 46297a6fbf321dfe4b85a3d2c1089614af8c9590d8352238c800ad69955b4b6a
version: "1.0"
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Content Management SDK For Python
---
## v1.4.0

#### Date: 09 June 2025

- Release 2.0 support.
- Nested Global fields support
---
## v1.3.3

#### Date: 12 May 2025
Expand Down
4 changes: 2 additions & 2 deletions contentstack_management/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@
)

__title__ = 'contentstack-management-python'
__author__ = 'ishaileshmishra'
__author__ = 'dev-ex'
__status__ = 'debug'
__region__ = 'na'
__version__ = '1.3.3'
__version__ = '1.4.0'
__host__ = 'api.contentstack.io'
__protocol__ = 'https://'
__api_version__ = 'v3'
Expand Down
2 changes: 0 additions & 2 deletions contentstack_management/auditlogs/auditlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
The create(), read(), update(), and delete() methods each correspond to
the CRUD operations that can be performed on the API """

import json
from ..common import Parameter
from urllib.parse import quote
from .._errors import ArgumentException

class Auditlog(Parameter):
Expand Down
92 changes: 92 additions & 0 deletions contentstack_management/bulk_operations/bulk_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,96 @@ def update(self, data: dict):
data = json.dumps(data)
return self.client.post(url, headers = self.client.headers, data = data, params=self.params)

def add_items(self, data: dict, headers: dict = None):
"""
The Add items to bulk operation request allows you to add multiple entries and assets to a bulk operation.

:return: The `add_items` method is returning the result of the `post` request made by the
`client.post` method.
-------------------------------
[Example:]
>>> data = {
>>> "release": "release_uid"
>>> "action": "publish",
>>> "locale": ["en-us", "hi-in"]
>>> "reference": true
>>> "items": [
>>> {
>>> "uid": "blt63177c0f00f20b61",
>>> "content_type_uid": "my_blog"
>>> }
>>> ]
>>> }
>>> import contentstack_management
>>> client = contentstack_management.Client(authtoken='your_authtoken')
>>> result = client.stack('api_key').bulk_operation().add_items(data).json()

-------------------------------
"""
if headers is not None:
self.client.headers.update(headers)
url = f"{self.path}/release/items"
data = json.dumps(data)
return self.client.post(url, headers = self.client.headers, data = data, params=self.params)

def update_items(self, data: dict, headers: dict = None):
"""
The update items to bulk operation request allows you to update multiple entries and assets to a bulk operation.

:return: The `update_items` method is returning the result of the `put` request made by the
`client.post` method.
-------------------------------
[Example:]
>>> data = {
>>> "release": "release_uid",
>>> "items": [
>>> {
>>> "uid": "entry_uid",
>>> "locale": "en-us"
>>> },
>>> {
>>> "uid": "entry_uid",
>>> "locale": "en-us",
>>> "variant_id": "entry_variant_id"
>>> }
>>> ]
>>> or
>>> [ '$all' ]
>>> }
>>> import contentstack_management
>>> client = contentstack_management.Client(authtoken='your_authtoken')
>>> result = client.stack('api_key').bulk_operation().update_items(data).json()

-------------------------------
"""
if headers is not None:
self.client.headers.update(headers)
url = f"{self.path}/release/update_items"
data = json.dumps(data)
return self.client.put(url, headers = self.client.headers, data = data, params=self.params)

def job_status(self, job_uid: str, headers: dict = None):
"""
The Job status request allows you to get the status of a bulk operation job.

:param job_uid: The `job_uid` parameter is a string that represents the unique identifier of the job
whose status you want to retrieve
:type job_uid: str
:return: The `job_status` method is returning the result of the `get` request made by the
`client.get` method.
-------------------------------
[Example:]
>>> import contentstack_management
>>> client = contentstack_management.Client(authtoken='your_authtoken')
>>> result = client.stack('api_key').bulk_operation().job_status('job_uid').json()

-------------------------------
"""
if job_uid is None:
raise ArgumentException("job_uid", "job_uid cannot be None")
if headers is not None:
self.client.headers.update(headers)
url = f"{self.path}/jobs/{quote(job_uid)}"
return self.client.get(url, headers = self.client.headers, params=self.params)


2 changes: 1 addition & 1 deletion contentstack_management/content_types/content_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def imports(self, file_path):
>>> response = content_type.imports()
--------------------------------
"""
url = f"content_types/import"
url = "content_types/import"
self.client.headers['Content-Type'] = "multipart/form-data"
files = {'content_type': open(f"{file_path}", 'rb')}
return self.client.post(url, headers=self.client.headers, params=self.params, files=files)
Expand Down
1 change: 0 additions & 1 deletion contentstack_management/contentstack.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import contentstack_management
from enum import Enum
from ._api_client import _APIClient
from contentstack_management.organizations import organization
Expand Down
1 change: 0 additions & 1 deletion contentstack_management/delivery_token/delivery_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import json
from ..common import Parameter
from urllib.parse import quote
from .._errors import ArgumentException

class DeliveryToken(Parameter):
Expand Down
1 change: 0 additions & 1 deletion contentstack_management/environments/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import json
from ..common import Parameter
from urllib.parse import quote
from .._errors import ArgumentException

class Environment(Parameter):
Expand Down
1 change: 0 additions & 1 deletion contentstack_management/extensions/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import json
from ..common import Parameter
from urllib.parse import quote
from .._errors import ArgumentException
from requests_toolbelt.multipart.encoder import MultipartEncoder

Expand Down
54 changes: 46 additions & 8 deletions contentstack_management/global_fields/global_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ class GlobalFields(Parameter):
methods each correspond to the CRUD
operations that can be performed on the API """

def __init__(self, client, global_field_uid=None):
def __init__(self, client, global_field_uid=None, options=None):
self.client = client
self.global_field_uid = global_field_uid
self.options = options
super().__init__(self.client)
if self.options and 'api_version' in self.options:
Parameter.add_header(self, 'api_version', str(self.options['api_version']))

def find(self):
"""
Expand All @@ -34,7 +37,12 @@ def find(self):
>>> result = client.stack("api_key").global_fields('global_field_uid').find().json()
-------------------------------
"""
return self.client.get(_path, headers=self.client.headers, params = self.params)
response = self.client.get(_path, headers=self.client.headers, params = self.params)
# Remove the api_version header after request
if self.options and 'api_version' in self.options:
self.client.headers.pop('api_version', None)

return response

def fetch(self):
"""
Expand All @@ -50,7 +58,12 @@ def fetch(self):
-------------------------------
"""
url = f"{_path}/{self.global_field_uid}"
return self.client.get(url, headers=self.client.headers, params = self.params)
response = self.client.get(url, headers=self.client.headers, params = self.params)
# Remove the api_version header after request
if self.options and 'api_version' in self.options:
self.client.headers.pop('api_version', None)

return response

def create(self, data):
"""
Expand All @@ -74,7 +87,12 @@ def create(self, data):
-------------------------------
"""
data = json.dumps(data)
return self.client.post(_path, headers=self.client.headers, data=data, params = self.params)
response = self.client.post(_path, headers=self.client.headers, data=data, params = self.params)
# Remove the api_version header after request
if self.options and 'api_version' in self.options:
self.client.headers.pop('api_version', None)

return response

def update(self, data):
"""
Expand All @@ -99,7 +117,12 @@ def update(self, data):
"""
url = f"{_path}/{self.global_field_uid}"
data = json.dumps(data)
return self.client.put(url, headers=self.client.headers, params=self.params, data=data)
response = self.client.put(url, headers=self.client.headers, params=self.params, data=data)
# Remove the api_version header after request
if self.options and 'api_version' in self.options:
self.client.headers.pop('api_version', None)

return response

def delete(self):
"""
Expand All @@ -114,7 +137,12 @@ def delete(self):
-------------------------------
"""
url = f"{_path}/{self.global_field_uid}"
return self.client.delete(url, headers=self.client.headers, params=self.params)
response = self.client.delete(url, headers=self.client.headers, params=self.params)
# Remove the api_version header after request
if self.options and 'api_version' in self.options:
self.client.headers.pop('api_version', None)

return response

def imports(self, file_path):
"""
Expand All @@ -131,7 +159,12 @@ def imports(self, file_path):
"""
self.client.headers['Content-Type'] = "multipart/form-data"
files = {'global_field': open(f"{file_path}", 'rb')}
return self.client.post('global_fields/import', headers=self.client.headers, params=self.params, files=files)
response = self.client.post('global_fields/import', headers=self.client.headers, params=self.params, files=files)
# Remove the api_version header after request
if self.options and 'api_version' in self.options:
self.client.headers.pop('api_version', None)

return response

def export(self):
"""
Expand All @@ -148,4 +181,9 @@ def export(self):
if self.global_field_uid is None or '':
raise Exception('global_field_uid is required')
url = f"{_path}/{self.global_field_uid}/export"
return self.client.get(url, headers=self.client.headers, params=self.params)
response = self.client.get(url, headers=self.client.headers, params=self.params)
# Remove the api_version header after request
if self.options and 'api_version' in self.options:
self.client.headers.pop('api_version', None)

return response
1 change: 0 additions & 1 deletion contentstack_management/labels/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import json
from ..common import Parameter
from urllib.parse import quote
from .._errors import ArgumentException

class Label(Parameter):
Expand Down
1 change: 0 additions & 1 deletion contentstack_management/locale/locale.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import json
from ..common import Parameter
from urllib.parse import quote
from .._errors import ArgumentException

class Locale(Parameter):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import json
from ..common import Parameter
from urllib.parse import quote
from .._errors import ArgumentException

class ManagementToken(Parameter):
Expand Down
1 change: 0 additions & 1 deletion contentstack_management/metadata/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import json
from ..common import Parameter
from urllib.parse import quote
from .._errors import ArgumentException

class Metadata(Parameter):
Expand Down
2 changes: 0 additions & 2 deletions contentstack_management/publish_queue/publish_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
The create(), read(), update(), and delete() methods each correspond to
the CRUD operations that can be performed on the API """

import json
from ..common import Parameter
from urllib.parse import quote
from .._errors import ArgumentException

class PublishQueue(Parameter):
Expand Down
Loading