Skip to content

Commit e297b6f

Browse files
Merge pull request #94 from contentstack/feat/dx-2991
Release 2.0 support added
2 parents 9f3fd68 + 0673297 commit e297b6f

File tree

98 files changed

+272
-183
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+272
-183
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Content Management SDK For Python
44
---
5+
## v1.4.0
6+
7+
#### Date: 26 May 2025
8+
9+
- Release 2.0 support.
10+
---
511
## v1.3.3
612

713
#### Date: 12 May 2025

contentstack_management/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
__author__ = 'dev-ex'
7373
__status__ = 'debug'
7474
__region__ = 'na'
75-
__version__ = '1.3.3'
75+
__version__ = '1.4.0'
7676
__host__ = 'api.contentstack.io'
7777
__protocol__ = 'https://'
7878
__api_version__ = 'v3'

contentstack_management/auditlogs/auditlog.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
The create(), read(), update(), and delete() methods each correspond to
44
the CRUD operations that can be performed on the API """
55

6-
import json
76
from ..common import Parameter
8-
from urllib.parse import quote
97
from .._errors import ArgumentException
108

119
class Auditlog(Parameter):

contentstack_management/bulk_operations/bulk_operation.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,96 @@ def update(self, data: dict):
227227
data = json.dumps(data)
228228
return self.client.post(url, headers = self.client.headers, data = data, params=self.params)
229229

230+
def add_items(self, data: dict, headers: dict = None):
231+
"""
232+
The Add items to bulk operation request allows you to add multiple entries and assets to a bulk operation.
233+
234+
:return: The `add_items` method is returning the result of the `post` request made by the
235+
`client.post` method.
236+
-------------------------------
237+
[Example:]
238+
>>> data = {
239+
>>> "release": "release_uid"
240+
>>> "action": "publish",
241+
>>> "locale": ["en-us", "hi-in"]
242+
>>> "reference": true
243+
>>> "items": [
244+
>>> {
245+
>>> "uid": "blt63177c0f00f20b61",
246+
>>> "content_type_uid": "my_blog"
247+
>>> }
248+
>>> ]
249+
>>> }
250+
>>> import contentstack_management
251+
>>> client = contentstack_management.Client(authtoken='your_authtoken')
252+
>>> result = client.stack('api_key').bulk_operation().add_items(data).json()
253+
254+
-------------------------------
255+
"""
256+
if headers is not None:
257+
self.client.headers.update(headers)
258+
url = f"{self.path}/release/items"
259+
data = json.dumps(data)
260+
return self.client.post(url, headers = self.client.headers, data = data, params=self.params)
261+
262+
def update_items(self, data: dict, headers: dict = None):
263+
"""
264+
The update items to bulk operation request allows you to update multiple entries and assets to a bulk operation.
265+
266+
:return: The `update_items` method is returning the result of the `put` request made by the
267+
`client.post` method.
268+
-------------------------------
269+
[Example:]
270+
>>> data = {
271+
>>> "release": "release_uid",
272+
>>> "items": [
273+
>>> {
274+
>>> "uid": "entry_uid",
275+
>>> "locale": "en-us"
276+
>>> },
277+
>>> {
278+
>>> "uid": "entry_uid",
279+
>>> "locale": "en-us",
280+
>>> "variant_id": "entry_variant_id"
281+
>>> }
282+
>>> ]
283+
>>> or
284+
>>> [ '$all' ]
285+
>>> }
286+
>>> import contentstack_management
287+
>>> client = contentstack_management.Client(authtoken='your_authtoken')
288+
>>> result = client.stack('api_key').bulk_operation().update_items(data).json()
289+
290+
-------------------------------
291+
"""
292+
if headers is not None:
293+
self.client.headers.update(headers)
294+
url = f"{self.path}/release/update_items"
295+
data = json.dumps(data)
296+
return self.client.put(url, headers = self.client.headers, data = data, params=self.params)
297+
298+
def job_status(self, job_uid: str, headers: dict = None):
299+
"""
300+
The Job status request allows you to get the status of a bulk operation job.
301+
302+
:param job_uid: The `job_uid` parameter is a string that represents the unique identifier of the job
303+
whose status you want to retrieve
304+
:type job_uid: str
305+
:return: The `job_status` method is returning the result of the `get` request made by the
306+
`client.get` method.
307+
-------------------------------
308+
[Example:]
309+
>>> import contentstack_management
310+
>>> client = contentstack_management.Client(authtoken='your_authtoken')
311+
>>> result = client.stack('api_key').bulk_operation().job_status('job_uid').json()
312+
313+
-------------------------------
314+
"""
315+
if job_uid is None:
316+
raise ArgumentException("job_uid", "job_uid cannot be None")
317+
if headers is not None:
318+
self.client.headers.update(headers)
319+
url = f"{self.path}/jobs/{quote(job_uid)}"
320+
return self.client.get(url, headers = self.client.headers, params=self.params)
321+
230322

contentstack_management/content_types/content_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ def imports(self, file_path):
340340
>>> response = content_type.imports()
341341
--------------------------------
342342
"""
343-
url = f"content_types/import"
343+
url = "content_types/import"
344344
self.client.headers['Content-Type'] = "multipart/form-data"
345345
files = {'content_type': open(f"{file_path}", 'rb')}
346346
return self.client.post(url, headers=self.client.headers, params=self.params, files=files)

contentstack_management/contentstack.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import contentstack_management
21
from enum import Enum
32
from ._api_client import _APIClient
43
from contentstack_management.organizations import organization

contentstack_management/delivery_token/delivery_token.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import json
77
from ..common import Parameter
8-
from urllib.parse import quote
98
from .._errors import ArgumentException
109

1110
class DeliveryToken(Parameter):

contentstack_management/environments/environment.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import json
77
from ..common import Parameter
8-
from urllib.parse import quote
98
from .._errors import ArgumentException
109

1110
class Environment(Parameter):

contentstack_management/extensions/extension.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import json
77
from ..common import Parameter
8-
from urllib.parse import quote
98
from .._errors import ArgumentException
109
from requests_toolbelt.multipart.encoder import MultipartEncoder
1110

contentstack_management/labels/label.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import json
77
from ..common import Parameter
8-
from urllib.parse import quote
98
from .._errors import ArgumentException
109

1110
class Label(Parameter):

0 commit comments

Comments
 (0)