Contentstack 1.8.0__tar.gz → 1.8.2__tar.gz

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.
Files changed (33) hide show
  1. Contentstack-1.8.2/Contentstack.egg-info/PKG-INFO +194 -0
  2. {Contentstack-1.8.0 → Contentstack-1.8.2}/Contentstack.egg-info/SOURCES.txt +1 -1
  3. Contentstack-1.8.2/PKG-INFO +194 -0
  4. Contentstack-1.8.2/README.md +170 -0
  5. {Contentstack-1.8.0 → Contentstack-1.8.2}/contentstack/__init__.py +12 -2
  6. {Contentstack-1.8.0 → Contentstack-1.8.2}/contentstack/entry.py +1 -3
  7. {Contentstack-1.8.0 → Contentstack-1.8.2}/contentstack/query.py +1 -3
  8. {Contentstack-1.8.0 → Contentstack-1.8.2}/contentstack/stack.py +12 -4
  9. {Contentstack-1.8.0 → Contentstack-1.8.2}/setup.py +20 -15
  10. {Contentstack-1.8.0 → Contentstack-1.8.2}/tests/test_assets.py +2 -2
  11. {Contentstack-1.8.0 → Contentstack-1.8.2}/tests/test_stack.py +24 -13
  12. Contentstack-1.8.0/Contentstack.egg-info/PKG-INFO +0 -166
  13. Contentstack-1.8.0/PKG-INFO +0 -166
  14. Contentstack-1.8.0/README.rst +0 -144
  15. {Contentstack-1.8.0 → Contentstack-1.8.2}/Contentstack.egg-info/dependency_links.txt +0 -0
  16. {Contentstack-1.8.0 → Contentstack-1.8.2}/Contentstack.egg-info/not-zip-safe +0 -0
  17. {Contentstack-1.8.0 → Contentstack-1.8.2}/Contentstack.egg-info/requires.txt +0 -0
  18. {Contentstack-1.8.0 → Contentstack-1.8.2}/Contentstack.egg-info/top_level.txt +0 -0
  19. {Contentstack-1.8.0 → Contentstack-1.8.2}/LICENSE +0 -0
  20. {Contentstack-1.8.0 → Contentstack-1.8.2}/contentstack/asset.py +0 -0
  21. {Contentstack-1.8.0 → Contentstack-1.8.2}/contentstack/assetquery.py +0 -0
  22. {Contentstack-1.8.0 → Contentstack-1.8.2}/contentstack/basequery.py +0 -0
  23. {Contentstack-1.8.0 → Contentstack-1.8.2}/contentstack/contenttype.py +0 -0
  24. {Contentstack-1.8.0 → Contentstack-1.8.2}/contentstack/controller.py +0 -0
  25. {Contentstack-1.8.0 → Contentstack-1.8.2}/contentstack/deep_merge_lp.py +0 -0
  26. {Contentstack-1.8.0 → Contentstack-1.8.2}/contentstack/entryqueryable.py +0 -0
  27. {Contentstack-1.8.0 → Contentstack-1.8.2}/contentstack/https_connection.py +0 -0
  28. {Contentstack-1.8.0 → Contentstack-1.8.2}/contentstack/image_transform.py +0 -0
  29. {Contentstack-1.8.0 → Contentstack-1.8.2}/contentstack/utility.py +0 -0
  30. {Contentstack-1.8.0 → Contentstack-1.8.2}/setup.cfg +0 -0
  31. {Contentstack-1.8.0 → Contentstack-1.8.2}/tests/test_entry.py +0 -0
  32. {Contentstack-1.8.0 → Contentstack-1.8.2}/tests/test_live_preview.py +0 -0
  33. {Contentstack-1.8.0 → Contentstack-1.8.2}/tests/test_query.py +0 -0
@@ -0,0 +1,194 @@
1
+ Metadata-Version: 2.1
2
+ Name: Contentstack
3
+ Version: 1.8.2
4
+ Summary: Contentstack is a headless CMS with an API-first approach.
5
+ Home-page: https://github.com/contentstack/contentstack-python
6
+ Author: Contentstack
7
+ Author-email: shailesh.mishra@contentstack.com, sunil.lakshman@contentstack.com
8
+ License: MIT
9
+ Keywords: contentstack-python
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Natural Language :: English
14
+ Classifier: Programming Language :: Python :: 3.6
15
+ Classifier: Programming Language :: Python :: 3.7
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Requires-Python: >=3.6
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: requests<3.0,>=2.20.0
23
+ Requires-Dist: python-dateutil
24
+
25
+ #[![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/)
26
+
27
+ <!-- ![Python package](https://github.com/contentstack/contentstack-python/workflows/Python%20package/badge.svg?branch=master) -->
28
+
29
+ ![build](https://img.shields.io/badge/build-passing-green?style=plastic)
30
+ ![Coverage](https://raw.githubusercontent.com/contentstack/contentstack-python/b4edf799276f586dce3e57fa5502036cd5fd8da3/coverage.svg) ![pip](https://img.shields.io/badge/pip-v1.8.0-blue?style=plastic) ![python](https://img.shields.io/badge/python-3.5|3.6|3.7|3.8-blue?style=plastic) [![GitHub license](https://img.shields.io/github/license/contentstack/contentstack-python?style=plastic)](https://github.com/contentstack/contentstack-python/blob/master/LICENSE) [![GitHub stars](https://img.shields.io/github/stars/contentstack/contentstack-python?style=plastic)](https://github.com/contentstack/contentstack-python/stargazers)
31
+
32
+ ## Python SDK for Contentstack
33
+
34
+ Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful
35
+ cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take
36
+ care of the rest. [Read More](https://www.contentstack.com/).
37
+
38
+ Contentstack provides Python SDK to build application on top of Python. Given below is the detailed guide and helpful
39
+ resources to get started with our Python SDK.
40
+
41
+ ### Prerequisite
42
+
43
+ You will need python 3 installed on your machine. You can install it
44
+ from [here](https://www.python.org/ftp/python/3.7.4/python-3.7.4-macosx10.9.pkg).
45
+
46
+ ### Setup and Installation
47
+
48
+ To use the Contentstack Python SDK to your existing project, perform the steps given below:
49
+
50
+ ### Install contentstack pip
51
+
52
+ ```pyhton
53
+ pip install contentstack
54
+ ```
55
+
56
+ Install latest [contentstack](https://pypi.org/project/Contentstack) package from the [PyPI](https://pypi.org)
57
+
58
+ This is the preferred method to install contentstack, as it will always install the most recent stable release. If you
59
+ don't have [pip](https://pip.pypa.io/) installed,
60
+ this [Python installation guide](http://docs.python-guide.org/en/latest/starting/installation/) can guide you through
61
+ the process
62
+
63
+ ### Key Concepts for using Contentstack
64
+
65
+ #### Stack
66
+
67
+ A stack is like a container that holds the content of your app. Learn more
68
+ about [Stacks](https://www.contentstack.com/docs/developers/set-up-stack).
69
+
70
+ #### Content Type
71
+
72
+ Content type lets you define the structure or blueprint of a page or a section of your digital property. It is a
73
+ form-like page that gives Content Managers an interface to input and upload
74
+ content. [Read more](https://www.contentstack.com/docs/developers/create-content-types).
75
+
76
+ #### Entry
77
+
78
+ An entry is the actual piece of content created using one of the defined content types. Learn more
79
+ about [Entries](https://www.contentstack.com/docs/content-managers/work-with-entries).
80
+
81
+ #### Asset
82
+
83
+ Assets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded to Contentstack. These files
84
+ can be used in multiple entries. Read more
85
+ about [Assets](https://www.contentstack.com/docs/content-managers/work-with-assets).
86
+
87
+ #### Environment
88
+
89
+ A publishing environment corresponds to one or more deployment servers or a content delivery destination where the
90
+ entries need to be published. Learn how to work
91
+ with [Environments](https://www.contentstack.com/docs/developers/set-up-environments).
92
+
93
+ ### Contentstack Python SDK: 5-minute Quickstart
94
+
95
+ #### Initializing your SDK
96
+
97
+ To initialize the SDK, specify application API key, access token, and environment name of the stack as shown in the
98
+ snippet given below, You can provide optional parameters for config:
99
+
100
+ ```python
101
+ stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
102
+ ```
103
+
104
+ To get the API credentials mentioned above, log in to your Contentstack account and then in your top panel navigation,
105
+ go to Settings &gt; Stack to view the API Key and Access Token.
106
+
107
+ #### Querying content from your stack
108
+
109
+ To retrieve a single entry from a content type use the code snippet given below:
110
+
111
+ ```python
112
+ stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
113
+ content_type = stack.content_type("content_type_uid")
114
+ entry = content_type.entry("entry_uid")
115
+ result = entry.fetch()
116
+ ```
117
+
118
+ ##### Get Multiple Entries
119
+
120
+ To retrieve multiple entries of a particular content type, use the code snippet given below:
121
+
122
+ ```python
123
+ stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
124
+ query = stack.content_type("content_type_uid").query()
125
+ result = query.find()
126
+ ```
127
+
128
+ ### Advanced Queries
129
+
130
+ You can query for content types, entries, assets and more using our Python API Reference.
131
+
132
+ [Python API Reference Doc](https://www.contentstack.com/docs/platforms/python/api-reference/)
133
+
134
+ ### Working with Images
135
+
136
+ We have introduced Image Delivery APIs that let you retrieve images and then manipulate and optimize them for your
137
+ digital properties. It lets you perform a host of other actions such as crop, trim, resize, rotate, overlay, and so on.
138
+
139
+ For example, if you want to crop an image (with width as 300 and height as 400), you simply need to append query
140
+ parameters at the end of the image URL, such as, `https://images.contentstack.io/v3/assets/download?crop=300,400`. There
141
+ are several more parameters that you can use for your images.
142
+
143
+ [Read Image Delivery API documentation](https://www.contentstack.com/docs/platforms/python/api-reference/).
144
+
145
+ You can use the Image Delivery API functions in this SDK as well. Here are a few examples of its usage in the SDK.
146
+
147
+ ```python
148
+ image = stack.image_transform(url, {'quality': 100}).get_url()
149
+ image = stack.image_transform(url, {'width': 100, 'height': 100}).get_url()
150
+ image = stack.image_transform(url, {'auto': 'webp'}).get_url()
151
+ ```
152
+
153
+ ### Using the Sync API with Python SDK
154
+
155
+ The Sync API takes care of syncing your Contentstack data with your application and ensures that the data is always
156
+ up-to-date by providing delta updates. Contentstack’s Python SDK supports Sync API, which you can use to build powerful
157
+ applications.
158
+
159
+ ```python
160
+ stack = contentstack.Stack('api_key', 'delivery_token', 'environment') # initialize sync
161
+ response = stack.sync_init() # sycn using sync token
162
+ response = stack.sync_token('sync_token') # sycn using pagination token
163
+ response = stack.pagination('pagination_token') # sync using multiple parameters
164
+ response = stack.sync_init(publish_type='entry_published', content_type_uid='content_type_uid')
165
+ ```
166
+
167
+ Read through to understand how to use the Sync API with Contentstack Python SDK.
168
+
169
+ [Using the Sync API with Python SDK](https://www.contentstack.com/docs/developers/python/using-the-sync-api-with-python-sdk)
170
+
171
+ ### Helpful Links
172
+
173
+ - [Contentstack Website](https://www.contentstack.com)
174
+ - [Official Documentation](https://contentstack.com/docs)
175
+ - [Content Delivery API Docs](https://www.contentstack.com/docs/developers/apis/content-delivery-api/)
176
+
177
+ ### The MIT License (MIT)
178
+
179
+ Copyright © 2012-2023 [Contentstack](https://www.contentstack.com/). All Rights Reserved
180
+
181
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
182
+ documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
183
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
184
+ persons to whom the Software is furnished to do so, subject to the following conditions:
185
+
186
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
187
+ Software.
188
+
189
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
190
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
191
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
192
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
193
+
194
+ - [Content Delivery API Docs](https://contentstack.com/docs/apis/content-delivery-api/)
@@ -1,5 +1,5 @@
1
1
  LICENSE
2
- README.rst
2
+ README.md
3
3
  setup.py
4
4
  Contentstack.egg-info/PKG-INFO
5
5
  Contentstack.egg-info/SOURCES.txt
@@ -0,0 +1,194 @@
1
+ Metadata-Version: 2.1
2
+ Name: Contentstack
3
+ Version: 1.8.2
4
+ Summary: Contentstack is a headless CMS with an API-first approach.
5
+ Home-page: https://github.com/contentstack/contentstack-python
6
+ Author: Contentstack
7
+ Author-email: shailesh.mishra@contentstack.com, sunil.lakshman@contentstack.com
8
+ License: MIT
9
+ Keywords: contentstack-python
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Natural Language :: English
14
+ Classifier: Programming Language :: Python :: 3.6
15
+ Classifier: Programming Language :: Python :: 3.7
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Requires-Python: >=3.6
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: requests<3.0,>=2.20.0
23
+ Requires-Dist: python-dateutil
24
+
25
+ #[![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/)
26
+
27
+ <!-- ![Python package](https://github.com/contentstack/contentstack-python/workflows/Python%20package/badge.svg?branch=master) -->
28
+
29
+ ![build](https://img.shields.io/badge/build-passing-green?style=plastic)
30
+ ![Coverage](https://raw.githubusercontent.com/contentstack/contentstack-python/b4edf799276f586dce3e57fa5502036cd5fd8da3/coverage.svg) ![pip](https://img.shields.io/badge/pip-v1.8.0-blue?style=plastic) ![python](https://img.shields.io/badge/python-3.5|3.6|3.7|3.8-blue?style=plastic) [![GitHub license](https://img.shields.io/github/license/contentstack/contentstack-python?style=plastic)](https://github.com/contentstack/contentstack-python/blob/master/LICENSE) [![GitHub stars](https://img.shields.io/github/stars/contentstack/contentstack-python?style=plastic)](https://github.com/contentstack/contentstack-python/stargazers)
31
+
32
+ ## Python SDK for Contentstack
33
+
34
+ Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful
35
+ cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take
36
+ care of the rest. [Read More](https://www.contentstack.com/).
37
+
38
+ Contentstack provides Python SDK to build application on top of Python. Given below is the detailed guide and helpful
39
+ resources to get started with our Python SDK.
40
+
41
+ ### Prerequisite
42
+
43
+ You will need python 3 installed on your machine. You can install it
44
+ from [here](https://www.python.org/ftp/python/3.7.4/python-3.7.4-macosx10.9.pkg).
45
+
46
+ ### Setup and Installation
47
+
48
+ To use the Contentstack Python SDK to your existing project, perform the steps given below:
49
+
50
+ ### Install contentstack pip
51
+
52
+ ```pyhton
53
+ pip install contentstack
54
+ ```
55
+
56
+ Install latest [contentstack](https://pypi.org/project/Contentstack) package from the [PyPI](https://pypi.org)
57
+
58
+ This is the preferred method to install contentstack, as it will always install the most recent stable release. If you
59
+ don't have [pip](https://pip.pypa.io/) installed,
60
+ this [Python installation guide](http://docs.python-guide.org/en/latest/starting/installation/) can guide you through
61
+ the process
62
+
63
+ ### Key Concepts for using Contentstack
64
+
65
+ #### Stack
66
+
67
+ A stack is like a container that holds the content of your app. Learn more
68
+ about [Stacks](https://www.contentstack.com/docs/developers/set-up-stack).
69
+
70
+ #### Content Type
71
+
72
+ Content type lets you define the structure or blueprint of a page or a section of your digital property. It is a
73
+ form-like page that gives Content Managers an interface to input and upload
74
+ content. [Read more](https://www.contentstack.com/docs/developers/create-content-types).
75
+
76
+ #### Entry
77
+
78
+ An entry is the actual piece of content created using one of the defined content types. Learn more
79
+ about [Entries](https://www.contentstack.com/docs/content-managers/work-with-entries).
80
+
81
+ #### Asset
82
+
83
+ Assets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded to Contentstack. These files
84
+ can be used in multiple entries. Read more
85
+ about [Assets](https://www.contentstack.com/docs/content-managers/work-with-assets).
86
+
87
+ #### Environment
88
+
89
+ A publishing environment corresponds to one or more deployment servers or a content delivery destination where the
90
+ entries need to be published. Learn how to work
91
+ with [Environments](https://www.contentstack.com/docs/developers/set-up-environments).
92
+
93
+ ### Contentstack Python SDK: 5-minute Quickstart
94
+
95
+ #### Initializing your SDK
96
+
97
+ To initialize the SDK, specify application API key, access token, and environment name of the stack as shown in the
98
+ snippet given below, You can provide optional parameters for config:
99
+
100
+ ```python
101
+ stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
102
+ ```
103
+
104
+ To get the API credentials mentioned above, log in to your Contentstack account and then in your top panel navigation,
105
+ go to Settings &gt; Stack to view the API Key and Access Token.
106
+
107
+ #### Querying content from your stack
108
+
109
+ To retrieve a single entry from a content type use the code snippet given below:
110
+
111
+ ```python
112
+ stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
113
+ content_type = stack.content_type("content_type_uid")
114
+ entry = content_type.entry("entry_uid")
115
+ result = entry.fetch()
116
+ ```
117
+
118
+ ##### Get Multiple Entries
119
+
120
+ To retrieve multiple entries of a particular content type, use the code snippet given below:
121
+
122
+ ```python
123
+ stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
124
+ query = stack.content_type("content_type_uid").query()
125
+ result = query.find()
126
+ ```
127
+
128
+ ### Advanced Queries
129
+
130
+ You can query for content types, entries, assets and more using our Python API Reference.
131
+
132
+ [Python API Reference Doc](https://www.contentstack.com/docs/platforms/python/api-reference/)
133
+
134
+ ### Working with Images
135
+
136
+ We have introduced Image Delivery APIs that let you retrieve images and then manipulate and optimize them for your
137
+ digital properties. It lets you perform a host of other actions such as crop, trim, resize, rotate, overlay, and so on.
138
+
139
+ For example, if you want to crop an image (with width as 300 and height as 400), you simply need to append query
140
+ parameters at the end of the image URL, such as, `https://images.contentstack.io/v3/assets/download?crop=300,400`. There
141
+ are several more parameters that you can use for your images.
142
+
143
+ [Read Image Delivery API documentation](https://www.contentstack.com/docs/platforms/python/api-reference/).
144
+
145
+ You can use the Image Delivery API functions in this SDK as well. Here are a few examples of its usage in the SDK.
146
+
147
+ ```python
148
+ image = stack.image_transform(url, {'quality': 100}).get_url()
149
+ image = stack.image_transform(url, {'width': 100, 'height': 100}).get_url()
150
+ image = stack.image_transform(url, {'auto': 'webp'}).get_url()
151
+ ```
152
+
153
+ ### Using the Sync API with Python SDK
154
+
155
+ The Sync API takes care of syncing your Contentstack data with your application and ensures that the data is always
156
+ up-to-date by providing delta updates. Contentstack’s Python SDK supports Sync API, which you can use to build powerful
157
+ applications.
158
+
159
+ ```python
160
+ stack = contentstack.Stack('api_key', 'delivery_token', 'environment') # initialize sync
161
+ response = stack.sync_init() # sycn using sync token
162
+ response = stack.sync_token('sync_token') # sycn using pagination token
163
+ response = stack.pagination('pagination_token') # sync using multiple parameters
164
+ response = stack.sync_init(publish_type='entry_published', content_type_uid='content_type_uid')
165
+ ```
166
+
167
+ Read through to understand how to use the Sync API with Contentstack Python SDK.
168
+
169
+ [Using the Sync API with Python SDK](https://www.contentstack.com/docs/developers/python/using-the-sync-api-with-python-sdk)
170
+
171
+ ### Helpful Links
172
+
173
+ - [Contentstack Website](https://www.contentstack.com)
174
+ - [Official Documentation](https://contentstack.com/docs)
175
+ - [Content Delivery API Docs](https://www.contentstack.com/docs/developers/apis/content-delivery-api/)
176
+
177
+ ### The MIT License (MIT)
178
+
179
+ Copyright © 2012-2023 [Contentstack](https://www.contentstack.com/). All Rights Reserved
180
+
181
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
182
+ documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
183
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
184
+ persons to whom the Software is furnished to do so, subject to the following conditions:
185
+
186
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
187
+ Software.
188
+
189
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
190
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
191
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
192
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
193
+
194
+ - [Content Delivery API Docs](https://contentstack.com/docs/apis/content-delivery-api/)
@@ -0,0 +1,170 @@
1
+ #[![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/)
2
+
3
+ <!-- ![Python package](https://github.com/contentstack/contentstack-python/workflows/Python%20package/badge.svg?branch=master) -->
4
+
5
+ ![build](https://img.shields.io/badge/build-passing-green?style=plastic)
6
+ ![Coverage](https://raw.githubusercontent.com/contentstack/contentstack-python/b4edf799276f586dce3e57fa5502036cd5fd8da3/coverage.svg) ![pip](https://img.shields.io/badge/pip-v1.8.0-blue?style=plastic) ![python](https://img.shields.io/badge/python-3.5|3.6|3.7|3.8-blue?style=plastic) [![GitHub license](https://img.shields.io/github/license/contentstack/contentstack-python?style=plastic)](https://github.com/contentstack/contentstack-python/blob/master/LICENSE) [![GitHub stars](https://img.shields.io/github/stars/contentstack/contentstack-python?style=plastic)](https://github.com/contentstack/contentstack-python/stargazers)
7
+
8
+ ## Python SDK for Contentstack
9
+
10
+ Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful
11
+ cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take
12
+ care of the rest. [Read More](https://www.contentstack.com/).
13
+
14
+ Contentstack provides Python SDK to build application on top of Python. Given below is the detailed guide and helpful
15
+ resources to get started with our Python SDK.
16
+
17
+ ### Prerequisite
18
+
19
+ You will need python 3 installed on your machine. You can install it
20
+ from [here](https://www.python.org/ftp/python/3.7.4/python-3.7.4-macosx10.9.pkg).
21
+
22
+ ### Setup and Installation
23
+
24
+ To use the Contentstack Python SDK to your existing project, perform the steps given below:
25
+
26
+ ### Install contentstack pip
27
+
28
+ ```pyhton
29
+ pip install contentstack
30
+ ```
31
+
32
+ Install latest [contentstack](https://pypi.org/project/Contentstack) package from the [PyPI](https://pypi.org)
33
+
34
+ This is the preferred method to install contentstack, as it will always install the most recent stable release. If you
35
+ don't have [pip](https://pip.pypa.io/) installed,
36
+ this [Python installation guide](http://docs.python-guide.org/en/latest/starting/installation/) can guide you through
37
+ the process
38
+
39
+ ### Key Concepts for using Contentstack
40
+
41
+ #### Stack
42
+
43
+ A stack is like a container that holds the content of your app. Learn more
44
+ about [Stacks](https://www.contentstack.com/docs/developers/set-up-stack).
45
+
46
+ #### Content Type
47
+
48
+ Content type lets you define the structure or blueprint of a page or a section of your digital property. It is a
49
+ form-like page that gives Content Managers an interface to input and upload
50
+ content. [Read more](https://www.contentstack.com/docs/developers/create-content-types).
51
+
52
+ #### Entry
53
+
54
+ An entry is the actual piece of content created using one of the defined content types. Learn more
55
+ about [Entries](https://www.contentstack.com/docs/content-managers/work-with-entries).
56
+
57
+ #### Asset
58
+
59
+ Assets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded to Contentstack. These files
60
+ can be used in multiple entries. Read more
61
+ about [Assets](https://www.contentstack.com/docs/content-managers/work-with-assets).
62
+
63
+ #### Environment
64
+
65
+ A publishing environment corresponds to one or more deployment servers or a content delivery destination where the
66
+ entries need to be published. Learn how to work
67
+ with [Environments](https://www.contentstack.com/docs/developers/set-up-environments).
68
+
69
+ ### Contentstack Python SDK: 5-minute Quickstart
70
+
71
+ #### Initializing your SDK
72
+
73
+ To initialize the SDK, specify application API key, access token, and environment name of the stack as shown in the
74
+ snippet given below, You can provide optional parameters for config:
75
+
76
+ ```python
77
+ stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
78
+ ```
79
+
80
+ To get the API credentials mentioned above, log in to your Contentstack account and then in your top panel navigation,
81
+ go to Settings &gt; Stack to view the API Key and Access Token.
82
+
83
+ #### Querying content from your stack
84
+
85
+ To retrieve a single entry from a content type use the code snippet given below:
86
+
87
+ ```python
88
+ stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
89
+ content_type = stack.content_type("content_type_uid")
90
+ entry = content_type.entry("entry_uid")
91
+ result = entry.fetch()
92
+ ```
93
+
94
+ ##### Get Multiple Entries
95
+
96
+ To retrieve multiple entries of a particular content type, use the code snippet given below:
97
+
98
+ ```python
99
+ stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
100
+ query = stack.content_type("content_type_uid").query()
101
+ result = query.find()
102
+ ```
103
+
104
+ ### Advanced Queries
105
+
106
+ You can query for content types, entries, assets and more using our Python API Reference.
107
+
108
+ [Python API Reference Doc](https://www.contentstack.com/docs/platforms/python/api-reference/)
109
+
110
+ ### Working with Images
111
+
112
+ We have introduced Image Delivery APIs that let you retrieve images and then manipulate and optimize them for your
113
+ digital properties. It lets you perform a host of other actions such as crop, trim, resize, rotate, overlay, and so on.
114
+
115
+ For example, if you want to crop an image (with width as 300 and height as 400), you simply need to append query
116
+ parameters at the end of the image URL, such as, `https://images.contentstack.io/v3/assets/download?crop=300,400`. There
117
+ are several more parameters that you can use for your images.
118
+
119
+ [Read Image Delivery API documentation](https://www.contentstack.com/docs/platforms/python/api-reference/).
120
+
121
+ You can use the Image Delivery API functions in this SDK as well. Here are a few examples of its usage in the SDK.
122
+
123
+ ```python
124
+ image = stack.image_transform(url, {'quality': 100}).get_url()
125
+ image = stack.image_transform(url, {'width': 100, 'height': 100}).get_url()
126
+ image = stack.image_transform(url, {'auto': 'webp'}).get_url()
127
+ ```
128
+
129
+ ### Using the Sync API with Python SDK
130
+
131
+ The Sync API takes care of syncing your Contentstack data with your application and ensures that the data is always
132
+ up-to-date by providing delta updates. Contentstack’s Python SDK supports Sync API, which you can use to build powerful
133
+ applications.
134
+
135
+ ```python
136
+ stack = contentstack.Stack('api_key', 'delivery_token', 'environment') # initialize sync
137
+ response = stack.sync_init() # sycn using sync token
138
+ response = stack.sync_token('sync_token') # sycn using pagination token
139
+ response = stack.pagination('pagination_token') # sync using multiple parameters
140
+ response = stack.sync_init(publish_type='entry_published', content_type_uid='content_type_uid')
141
+ ```
142
+
143
+ Read through to understand how to use the Sync API with Contentstack Python SDK.
144
+
145
+ [Using the Sync API with Python SDK](https://www.contentstack.com/docs/developers/python/using-the-sync-api-with-python-sdk)
146
+
147
+ ### Helpful Links
148
+
149
+ - [Contentstack Website](https://www.contentstack.com)
150
+ - [Official Documentation](https://contentstack.com/docs)
151
+ - [Content Delivery API Docs](https://www.contentstack.com/docs/developers/apis/content-delivery-api/)
152
+
153
+ ### The MIT License (MIT)
154
+
155
+ Copyright © 2012-2023 [Contentstack](https://www.contentstack.com/). All Rights Reserved
156
+
157
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
158
+ documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
159
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
160
+ persons to whom the Software is furnished to do so, subject to the following conditions:
161
+
162
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
163
+ Software.
164
+
165
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
166
+ WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
167
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
168
+ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
169
+
170
+ - [Content Delivery API Docs](https://contentstack.com/docs/apis/content-delivery-api/)
@@ -10,10 +10,20 @@ from .https_connection import HTTPSConnection
10
10
  from contentstack.stack import Stack
11
11
  from .utility import Utils
12
12
 
13
- __title__ = 'contentstack-python'
13
+ __all__ = (
14
+ "Entry",
15
+ "Asset",
16
+ "ContentType",
17
+ "HTTPSConnection",
18
+ "Stack",
19
+ "Utils"
20
+ )
21
+
22
+ __title__ = 'contentstack-delivery-python'
14
23
  __author__ = 'contentstack'
15
24
  __status__ = 'debug'
16
- __version__ = 'v1.8.0'
25
+ __version__ = 'v1.8.2'
17
26
  __endpoint__ = 'cdn.contentstack.io'
18
27
  __email__ = 'mobile@contentstack.com'
19
28
  __developer_email__ = 'shailesh.mishra@contentstack.com'
29
+ __license__ = "MIT"
@@ -6,8 +6,6 @@ API Reference: https://www.contentstack.com/docs/developers/apis/content-deliver
6
6
  import logging
7
7
  from urllib import parse
8
8
 
9
- import empty
10
-
11
9
  from contentstack.deep_merge_lp import DeepMergeMixin
12
10
  from contentstack.entryqueryable import EntryQueryable
13
11
 
@@ -157,7 +155,7 @@ class Entry(EntryQueryable):
157
155
  return self
158
156
 
159
157
  def __get_base_url(self, endpoint=''):
160
- if endpoint is not None and not empty:
158
+ if endpoint is not None and endpoint.strip(): # .strip() removes leading/trailing whitespace
161
159
  self.http_instance.endpoint = endpoint
162
160
  if None in (self.http_instance, self.content_type_id, self.entry_uid):
163
161
  raise KeyError(
@@ -8,8 +8,6 @@ import logging
8
8
  import warnings
9
9
  from urllib import parse
10
10
 
11
- import empty
12
-
13
11
  from contentstack.basequery import BaseQuery
14
12
  from contentstack.deep_merge_lp import DeepMergeMixin
15
13
  from contentstack.entryqueryable import EntryQueryable
@@ -54,7 +52,7 @@ class Query(BaseQuery, EntryQueryable):
54
52
  self.base_url = self.__get_base_url()
55
53
 
56
54
  def __get_base_url(self, endpoint=''):
57
- if endpoint is not None and not empty:
55
+ if endpoint is not None and endpoint.strip(): # .strip() removes leading/trailing whitespace
58
56
  self.http_instance.endpoint = endpoint
59
57
  if None in (self.http_instance, self.content_type_uid):
60
58
  raise KeyError(