Contentstack 0.1.0__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.
@@ -0,0 +1,146 @@
1
+ Metadata-Version: 2.1
2
+ Name: contentstack
3
+ Version: 0.1.0
4
+ Summary: Python SDK for Contentstack's Content Delivery API
5
+ Home-page: https://github.com/contentstack/contentstack-python.git
6
+ Author: Contentstack
7
+ Author-email: mshaileshr@gmail.com
8
+ License: MIT License
9
+ Description: [![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/)
10
+
11
+ ## Python SDK for Contentstack
12
+
13
+ Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. [Read More](https://www.contentstack.com/).
14
+
15
+ Contentstack provides Python SDK to build application on top of Python. Given below is the detailed guide and helpful resources to get started with our Python SDK.
16
+
17
+
18
+ ### Prerequisite
19
+
20
+ You will need python 3 installed on your machine. You can install it 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
+ ```
29
+ pip install contentstack
30
+ ```
31
+
32
+
33
+ ### Key Concepts for using Contentstack
34
+
35
+ #### Stack
36
+
37
+ A stack is like a container that holds the content of your app. Learn more about [Stacks](https://www.contentstack.com/docs/guide/stack).
38
+
39
+ #### Content Type
40
+
41
+ Content type lets you define the structure or blueprint of a page or a section of your digital property. It is a form-like page that gives Content Managers an interface to input and upload content. [Read more](https://www.contentstack.com/docs/guide/content-types).
42
+
43
+ #### Entry
44
+
45
+ An entry is the actual piece of content created using one of the defined content types. Learn more about [Entries](https://www.contentstack.com/docs/guide/content-management#working-with-entries).
46
+
47
+ #### Asset
48
+
49
+ Assets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded to Contentstack. These files can be used in multiple entries. Read more about [Assets](https://www.contentstack.com/docs/guide/content-management#working-with-assets).
50
+
51
+ #### Environment
52
+
53
+ A publishing environment corresponds to one or more deployment servers or a content delivery destination where the entries need to be published. Learn how to work with [Environments](https://www.contentstack.com/docs/guide/environments).
54
+
55
+
56
+
57
+ ### Contentstack Python SDK: 5-minute Quickstart
58
+
59
+ #### Initializing your SDK
60
+
61
+ To initialize the SDK, specify application API key, access token, and environment name of the stack as shown in the snippet given below (config is optional):
62
+ ```
63
+ stack = contentstack.Stack(api_key='api_key', access_token='access_token', environment='environment', config=config)
64
+ ```
65
+ To get the API credentials mentioned above, log in to your Contentstack account and then in your top panel navigation, go to Settings > Stack to view the API Key and Access Token.
66
+
67
+
68
+
69
+ #### Querying content from your stack
70
+
71
+ To retrieve a single entry from a content type use the code snippet given below:
72
+
73
+ ```
74
+ content_type = stack.content_type("content_type_uid")
75
+ entry = content_type.entry("entry_uid")
76
+ result = entry.fetch()
77
+ ```
78
+ ##### Get Multiple Entries
79
+
80
+ To retrieve multiple entries of a particular content type, use the code snippet given below:
81
+
82
+ ```
83
+ //stack is an instance of Stack class
84
+ query = stack.content_type("content_type_uid").query()
85
+ result = query.find()
86
+ ```
87
+
88
+
89
+ ### Advanced Queries
90
+
91
+ You can query for content types, entries, assets and more using our Java API Reference.
92
+
93
+ [Python API Reference Doc](https://www.contentstack.com/docs/platforms/python/api-reference/)
94
+
95
+ ### Working with Images
96
+
97
+ We have introduced Image Delivery APIs that let you retrieve images and then manipulate and optimize them for your digital properties. It lets you perform a host of other actions such as crop, trim, resize, rotate, overlay, and so on.
98
+
99
+ For example, if you want to crop an image (with width as 300 and height as 400), you simply need to append query parameters at the end of the image URL, such as, https://images.contentstack.io/v3/assets/blteae40eb499811073/bltc5064f36b5855343/59e0c41ac0eddd140d5a8e3e/download?crop=300,400. There are several more parameters that you can use for your images.
100
+
101
+ [Read Image Delivery API documentation](https://www.contentstack.com/docs/apis/image-delivery-api/).
102
+
103
+ You can use the Image Delivery API functions in this SDK as well. Here are a few examples of its usage in the SDK.
104
+
105
+ ```
106
+ //set the image quality to 100
107
+ image_params = {'quality': 100}
108
+ imageUrl = stack.image_transform(image_url, **image_params);
109
+
110
+ //resize the image by specifying width and height
111
+ image_params = {'width': 100, 'height': 100}
112
+ imageUrl = stack.image_transform(imageUrl, **image_params);
113
+
114
+ //enable auto optimization for the image
115
+ image_params = {'auto': 'webp'}
116
+ imageUrl = stack.image_transform(imageUrl, **imageParams);
117
+ ```
118
+
119
+
120
+
121
+ ### Helpful Links
122
+
123
+ - [Contentstack Website](https://www.contentstack.com)
124
+ - [Official Documentation](https://contentstack.com/docs)
125
+ - [Content Delivery API Docs](https://contentstack.com/docs/apis/content-delivery-api/)
126
+
127
+
128
+ ### The MIT License (MIT)
129
+
130
+ Copyright © 2012-2019 [Contentstack](https://www.contentstack.com/). All Rights Reserved
131
+
132
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
133
+
134
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
135
+
136
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
137
+ Keywords: contentstack content delivery API,CMS
138
+ Platform: UNKNOWN
139
+ Classifier: License :: OSI Approved :: MIT License
140
+ Classifier: Operating System :: OS Independent
141
+ Classifier: Intended Audience :: Developers
142
+ Classifier: Natural Language :: English
143
+ Classifier: Programming Language :: Python :: 3.6
144
+ Classifier: Programming Language :: Python :: 3.7
145
+ Requires-Python: >=3.6
146
+ Description-Content-Type: text/markdown
@@ -0,0 +1,128 @@
1
+ [![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/)
2
+
3
+ ## Python SDK for Contentstack
4
+
5
+ Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. [Read More](https://www.contentstack.com/).
6
+
7
+ Contentstack provides Python SDK to build application on top of Python. Given below is the detailed guide and helpful resources to get started with our Python SDK.
8
+
9
+
10
+ ### Prerequisite
11
+
12
+ You will need python 3 installed on your machine. You can install it from [here](https://www.python.org/ftp/python/3.7.4/python-3.7.4-macosx10.9.pkg).
13
+
14
+ ### Setup and Installation
15
+
16
+ To use the Contentstack Python SDK to your existing project, perform the steps given below:
17
+
18
+ **Install contentstack pip**
19
+
20
+ ```
21
+ pip install contentstack
22
+ ```
23
+
24
+
25
+ ### Key Concepts for using Contentstack
26
+
27
+ #### Stack
28
+
29
+ A stack is like a container that holds the content of your app. Learn more about [Stacks](https://www.contentstack.com/docs/guide/stack).
30
+
31
+ #### Content Type
32
+
33
+ Content type lets you define the structure or blueprint of a page or a section of your digital property. It is a form-like page that gives Content Managers an interface to input and upload content. [Read more](https://www.contentstack.com/docs/guide/content-types).
34
+
35
+ #### Entry
36
+
37
+ An entry is the actual piece of content created using one of the defined content types. Learn more about [Entries](https://www.contentstack.com/docs/guide/content-management#working-with-entries).
38
+
39
+ #### Asset
40
+
41
+ Assets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded to Contentstack. These files can be used in multiple entries. Read more about [Assets](https://www.contentstack.com/docs/guide/content-management#working-with-assets).
42
+
43
+ #### Environment
44
+
45
+ A publishing environment corresponds to one or more deployment servers or a content delivery destination where the entries need to be published. Learn how to work with [Environments](https://www.contentstack.com/docs/guide/environments).
46
+
47
+
48
+
49
+ ### Contentstack Python SDK: 5-minute Quickstart
50
+
51
+ #### Initializing your SDK
52
+
53
+ To initialize the SDK, specify application API key, access token, and environment name of the stack as shown in the snippet given below (config is optional):
54
+ ```
55
+ stack = contentstack.Stack(api_key='api_key', access_token='access_token', environment='environment', config=config)
56
+ ```
57
+ To get the API credentials mentioned above, log in to your Contentstack account and then in your top panel navigation, go to Settings > Stack to view the API Key and Access Token.
58
+
59
+
60
+
61
+ #### Querying content from your stack
62
+
63
+ To retrieve a single entry from a content type use the code snippet given below:
64
+
65
+ ```
66
+ content_type = stack.content_type("content_type_uid")
67
+ entry = content_type.entry("entry_uid")
68
+ result = entry.fetch()
69
+ ```
70
+ ##### Get Multiple Entries
71
+
72
+ To retrieve multiple entries of a particular content type, use the code snippet given below:
73
+
74
+ ```
75
+ //stack is an instance of Stack class
76
+ query = stack.content_type("content_type_uid").query()
77
+ result = query.find()
78
+ ```
79
+
80
+
81
+ ### Advanced Queries
82
+
83
+ You can query for content types, entries, assets and more using our Java API Reference.
84
+
85
+ [Python API Reference Doc](https://www.contentstack.com/docs/platforms/python/api-reference/)
86
+
87
+ ### Working with Images
88
+
89
+ We have introduced Image Delivery APIs that let you retrieve images and then manipulate and optimize them for your digital properties. It lets you perform a host of other actions such as crop, trim, resize, rotate, overlay, and so on.
90
+
91
+ For example, if you want to crop an image (with width as 300 and height as 400), you simply need to append query parameters at the end of the image URL, such as, https://images.contentstack.io/v3/assets/blteae40eb499811073/bltc5064f36b5855343/59e0c41ac0eddd140d5a8e3e/download?crop=300,400. There are several more parameters that you can use for your images.
92
+
93
+ [Read Image Delivery API documentation](https://www.contentstack.com/docs/apis/image-delivery-api/).
94
+
95
+ You can use the Image Delivery API functions in this SDK as well. Here are a few examples of its usage in the SDK.
96
+
97
+ ```
98
+ //set the image quality to 100
99
+ image_params = {'quality': 100}
100
+ imageUrl = stack.image_transform(image_url, **image_params);
101
+
102
+ //resize the image by specifying width and height
103
+ image_params = {'width': 100, 'height': 100}
104
+ imageUrl = stack.image_transform(imageUrl, **image_params);
105
+
106
+ //enable auto optimization for the image
107
+ image_params = {'auto': 'webp'}
108
+ imageUrl = stack.image_transform(imageUrl, **imageParams);
109
+ ```
110
+
111
+
112
+
113
+ ### Helpful Links
114
+
115
+ - [Contentstack Website](https://www.contentstack.com)
116
+ - [Official Documentation](https://contentstack.com/docs)
117
+ - [Content Delivery API Docs](https://contentstack.com/docs/apis/content-delivery-api/)
118
+
119
+
120
+ ### The MIT License (MIT)
121
+
122
+ Copyright © 2012-2019 [Contentstack](https://www.contentstack.com/). All Rights Reserved
123
+
124
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
125
+
126
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
127
+
128
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+
2
+ """
3
+ __init__.py
4
+ contentstack
5
+ Created by Shailesh Mishra on 22/06/19.
6
+ Copyright 2019 Contentstack. All rights reserved.
7
+ """
8
+
9
+ import warnings
10
+
11
+ __author__ = 'Contentstack'
12
+ __status__ = 'debug'
13
+ __version__ = '0.1.0'
14
+ __package__ = 'contentstack'
15
+ __endpoint__ = 'cdn.contentstack.io'
16
+ __email__ = "mobile@contentstack.com"
17
+
18
+ from .entry import Entry
19
+ from .asset import Asset
20
+ from .config import Config
21
+ from .content_type import ContentType
22
+ from .errors import Error, FileModeWarning
23
+ from .http_connection import HTTPConnection
24
+ from .stack import Stack
25
+
26
+ import logging
27
+ from logging import NullHandler
28
+ logging.getLogger(__name__).addHandler(NullHandler())
29
+ warnings.simplefilter('default', FileModeWarning, append=True)