Contentstack 2.6.1__py3-none-any.whl → 2.7.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- contentstack/__init__.py +1 -1
- contentstack/contenttype.py +6 -3
- contentstack/entry.py +6 -3
- contentstack/variants.py +30 -16
- {contentstack-2.6.1.dist-info → contentstack-2.7.1.dist-info}/METADATA +1 -1
- {contentstack-2.6.1.dist-info → contentstack-2.7.1.dist-info}/RECORD +9 -9
- {contentstack-2.6.1.dist-info → contentstack-2.7.1.dist-info}/WHEEL +0 -0
- {contentstack-2.6.1.dist-info → contentstack-2.7.1.dist-info}/licenses/LICENSE +0 -0
- {contentstack-2.6.1.dist-info → contentstack-2.7.1.dist-info}/top_level.txt +0 -0
contentstack/__init__.py
CHANGED
|
@@ -42,7 +42,7 @@ def get_contentstack_endpoint(region='us', service='', omit_https=False):
|
|
|
42
42
|
__title__ = 'contentstack-delivery-python'
|
|
43
43
|
__author__ = 'contentstack'
|
|
44
44
|
__status__ = 'debug'
|
|
45
|
-
__version__ = 'v2.
|
|
45
|
+
__version__ = 'v2.7.1'
|
|
46
46
|
__endpoint__ = 'cdn.contentstack.io'
|
|
47
47
|
__email__ = 'support@contentstack.com'
|
|
48
48
|
__developer_email__ = 'mobile@contentstack.com'
|
contentstack/contenttype.py
CHANGED
|
@@ -119,17 +119,20 @@ class ContentType:
|
|
|
119
119
|
result = self.http_instance.get(url)
|
|
120
120
|
return result
|
|
121
121
|
|
|
122
|
-
def variants(self, variant_uid: str | list[str], params: dict = None):
|
|
122
|
+
def variants(self, variant_uid: str | list[str], branch: str = None, params: dict = None):
|
|
123
123
|
"""
|
|
124
124
|
Fetches the variants of the content type
|
|
125
|
-
:param variant_uid: {str} --
|
|
126
|
-
:
|
|
125
|
+
:param variant_uid: {str | list[str]} -- variant UID or list of variant UIDs
|
|
126
|
+
:param branch: {str} -- optional branch name to scope the variant request
|
|
127
|
+
:param params: {dict} -- optional query parameters
|
|
128
|
+
:return: Variants, so you can chain this call.
|
|
127
129
|
"""
|
|
128
130
|
return Variants(
|
|
129
131
|
http_instance=self.http_instance,
|
|
130
132
|
content_type_uid=self.__content_type_uid,
|
|
131
133
|
entry_uid=None,
|
|
132
134
|
variant_uid=variant_uid,
|
|
135
|
+
branch=branch,
|
|
133
136
|
params=params,
|
|
134
137
|
logger=None
|
|
135
138
|
)
|
contentstack/entry.py
CHANGED
|
@@ -267,17 +267,20 @@ class Entry(EntryQueryable):
|
|
|
267
267
|
return merged_response # Now correctly returns a dictionary
|
|
268
268
|
raise ValueError(ErrorMessages.MISSING_LIVE_PREVIEW_KEYS)
|
|
269
269
|
|
|
270
|
-
def variants(self, variant_uid: str | list[str], params: dict = None):
|
|
270
|
+
def variants(self, variant_uid: str | list[str], branch: str = None, params: dict = None):
|
|
271
271
|
"""
|
|
272
272
|
Fetches the variants of the entry
|
|
273
|
-
:param variant_uid: {str} --
|
|
274
|
-
:
|
|
273
|
+
:param variant_uid: {str | list[str]} -- variant UID or list of variant UIDs
|
|
274
|
+
:param branch: {str} -- optional branch name to scope the variant request
|
|
275
|
+
:param params: {dict} -- optional query parameters
|
|
276
|
+
:return: Variants, so you can chain this call.
|
|
275
277
|
"""
|
|
276
278
|
return Variants(
|
|
277
279
|
http_instance=self.http_instance,
|
|
278
280
|
content_type_uid=self.content_type_id,
|
|
279
281
|
entry_uid=self.entry_uid,
|
|
280
282
|
variant_uid=variant_uid,
|
|
283
|
+
branch=branch,
|
|
281
284
|
params=params,
|
|
282
285
|
logger=self.logger
|
|
283
286
|
)
|
contentstack/variants.py
CHANGED
|
@@ -20,6 +20,7 @@ class Variants(EntryQueryable):
|
|
|
20
20
|
content_type_uid=None,
|
|
21
21
|
entry_uid=None,
|
|
22
22
|
variant_uid=None,
|
|
23
|
+
branch=None,
|
|
23
24
|
params=None,
|
|
24
25
|
logger=None):
|
|
25
26
|
|
|
@@ -30,29 +31,47 @@ class Variants(EntryQueryable):
|
|
|
30
31
|
self.content_type_id = content_type_uid
|
|
31
32
|
self.entry_uid = entry_uid
|
|
32
33
|
self.variant_uid = variant_uid
|
|
34
|
+
self.branch = branch
|
|
33
35
|
self.logger = logger or logging.getLogger(__name__)
|
|
34
36
|
self.entry_param = params or {}
|
|
35
37
|
|
|
38
|
+
def _prepare_variant_headers(self):
|
|
39
|
+
headers = self.http_instance.headers.copy()
|
|
40
|
+
if isinstance(self.variant_uid, str):
|
|
41
|
+
headers['x-cs-variant-uid'] = self.variant_uid
|
|
42
|
+
elif isinstance(self.variant_uid, list):
|
|
43
|
+
headers['x-cs-variant-uid'] = ','.join(self.variant_uid)
|
|
44
|
+
if self.branch is not None:
|
|
45
|
+
headers['branch'] = self.branch
|
|
46
|
+
return headers
|
|
47
|
+
|
|
48
|
+
def _apply_variant_headers(self, headers):
|
|
49
|
+
self._original_branch = self.http_instance.headers.get('branch')
|
|
50
|
+
self.http_instance.headers.update(headers)
|
|
51
|
+
|
|
52
|
+
def _cleanup_variant_headers(self):
|
|
53
|
+
self.http_instance.headers.pop('x-cs-variant-uid', None)
|
|
54
|
+
if self.branch is not None:
|
|
55
|
+
if self._original_branch is not None:
|
|
56
|
+
self.http_instance.headers['branch'] = self._original_branch
|
|
57
|
+
else:
|
|
58
|
+
self.http_instance.headers.pop('branch', None)
|
|
59
|
+
|
|
36
60
|
def find(self, params=None):
|
|
37
61
|
"""
|
|
38
62
|
find the variants of the entry of a particular content type
|
|
39
63
|
:param self.variant_uid: {str} -- self.variant_uid
|
|
40
64
|
:return: Entry, so you can chain this call.
|
|
41
65
|
"""
|
|
42
|
-
headers = self.
|
|
43
|
-
if isinstance(self.variant_uid, str):
|
|
44
|
-
headers['x-cs-variant-uid'] = self.variant_uid
|
|
45
|
-
elif isinstance(self.variant_uid, list):
|
|
46
|
-
headers['x-cs-variant-uid'] = ','.join(self.variant_uid)
|
|
47
|
-
|
|
66
|
+
headers = self._prepare_variant_headers()
|
|
48
67
|
if params is not None:
|
|
49
68
|
self.entry_param.update(params)
|
|
50
69
|
encoded_params = parse.urlencode(self.entry_param)
|
|
51
70
|
endpoint = self.http_instance.endpoint
|
|
52
71
|
url = f'{endpoint}/content_types/{self.content_type_id}/entries?{encoded_params}'
|
|
53
|
-
self.
|
|
72
|
+
self._apply_variant_headers(headers)
|
|
54
73
|
result = self.http_instance.get(url)
|
|
55
|
-
self.
|
|
74
|
+
self._cleanup_variant_headers()
|
|
56
75
|
return result
|
|
57
76
|
|
|
58
77
|
def fetch(self, params=None):
|
|
@@ -77,18 +96,13 @@ class Variants(EntryQueryable):
|
|
|
77
96
|
if self.entry_uid is None:
|
|
78
97
|
raise ValueError(ErrorMessages.ENTRY_UID_REQUIRED)
|
|
79
98
|
else:
|
|
80
|
-
headers = self.
|
|
81
|
-
if isinstance(self.variant_uid, str):
|
|
82
|
-
headers['x-cs-variant-uid'] = self.variant_uid
|
|
83
|
-
elif isinstance(self.variant_uid, list):
|
|
84
|
-
headers['x-cs-variant-uid'] = ','.join(self.variant_uid)
|
|
85
|
-
|
|
99
|
+
headers = self._prepare_variant_headers()
|
|
86
100
|
if params is not None:
|
|
87
101
|
self.entry_param.update(params)
|
|
88
102
|
encoded_params = parse.urlencode(self.entry_param)
|
|
89
103
|
endpoint = self.http_instance.endpoint
|
|
90
104
|
url = f'{endpoint}/content_types/{self.content_type_id}/entries/{self.entry_uid}?{encoded_params}'
|
|
91
|
-
self.
|
|
105
|
+
self._apply_variant_headers(headers)
|
|
92
106
|
result = self.http_instance.get(url)
|
|
93
|
-
self.
|
|
107
|
+
self._cleanup_variant_headers()
|
|
94
108
|
return result
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
contentstack/__init__.py,sha256=
|
|
1
|
+
contentstack/__init__.py,sha256=EsRklKO4Pjx5XK4xG1oftKOAuHb7HxS8WGfZtBRz_ew,1680
|
|
2
2
|
contentstack/asset.py,sha256=GY-eC9Tg2uEDr9S7ggXCcrMjIdkcQGkP4UNgTfIqFs0,6977
|
|
3
3
|
contentstack/assetquery.py,sha256=FisGJ02MmH4sYvnHEJhYj4OWZBRORV8iKy38PdzLtxY,7954
|
|
4
4
|
contentstack/basequery.py,sha256=c_A7Pi45OHHfCpd8_ZjcIYAy9mhZ7CXlbBiZ4Plnu3M,6605
|
|
5
|
-
contentstack/contenttype.py,sha256=
|
|
5
|
+
contentstack/contenttype.py,sha256=16gz2NmS2U8FAT7phRf5UeKDjGAM3JNcIRcP3EDyO5Y,5649
|
|
6
6
|
contentstack/controller.py,sha256=kcFnVdvFJk6_HYgK60-cUgyEK3C1UlD98zv108JtcVI,1095
|
|
7
7
|
contentstack/deep_merge_lp.py,sha256=PIRGo5Dv60g4hzBY__nOrIAKgIx1Pd36gGzxnM5gZK4,1575
|
|
8
8
|
contentstack/endpoint.py,sha256=8ZTPDlpQ0C1oa3EgU_nbcHjFeQ5Chgen8viUFCVGk3w,6579
|
|
9
|
-
contentstack/entry.py,sha256=
|
|
9
|
+
contentstack/entry.py,sha256=j3YPTxAevwpolOtKShTn4mdaMFyUkAE4koz8FrTqkFM,12547
|
|
10
10
|
contentstack/entryqueryable.py,sha256=4YBX4N6tNSPMavrPxzM26RFBH8Qi6pIalIu-KEdVOtE,9828
|
|
11
11
|
contentstack/error_messages.py,sha256=Qep3wvN2Rl0lb1UIRGCjzpHBGnpXaortaescCdNuMHY,3334
|
|
12
12
|
contentstack/globalfields.py,sha256=APhIpiAVJ2v7Illh6yS4-S6W8yEzXBtYpAaPUKD-XuQ,2865
|
|
@@ -17,9 +17,9 @@ contentstack/region_refresh.py,sha256=zXwsMwVMSMb7duhqhV_Zx5aOHqsQE_6pnSppPLVteW
|
|
|
17
17
|
contentstack/stack.py,sha256=Xu7iS117AL3q1vhlYNEC97lPho91yrGxBiwk0htAZU8,16948
|
|
18
18
|
contentstack/taxonomy.py,sha256=g6zey4MkoeQqxRlHLSuzbA2NfbphgogGBXAwk28P5KI,2339
|
|
19
19
|
contentstack/utility.py,sha256=qZWckUMZZh4F80A7gV9qHn9QKOhr099M8FiJKxtxdao,3169
|
|
20
|
-
contentstack/variants.py,sha256=
|
|
21
|
-
contentstack-2.
|
|
22
|
-
contentstack-2.
|
|
23
|
-
contentstack-2.
|
|
24
|
-
contentstack-2.
|
|
25
|
-
contentstack-2.
|
|
20
|
+
contentstack/variants.py,sha256=lNaiPfx9126MmlNvlALEomX5z0I8Q0YhqqwhMt2fHH8,4130
|
|
21
|
+
contentstack-2.7.1.dist-info/licenses/LICENSE,sha256=BF_N9KC72HmX8HTAJROoPoFrW6xmO3rlbqpfjxmli08,1099
|
|
22
|
+
contentstack-2.7.1.dist-info/METADATA,sha256=FZwCl7m8LokO0N2cBGdCmhnU04fzQQX4I_quGmOiEUw,9346
|
|
23
|
+
contentstack-2.7.1.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
|
|
24
|
+
contentstack-2.7.1.dist-info/top_level.txt,sha256=jMUc8tWMXdbMFbvosYZ-vHWHrsLFWeHgrWQytLTVZf4,13
|
|
25
|
+
contentstack-2.7.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|