Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
15e81cf
:potted_plant: formating updated
ishaileshmishra Apr 12, 2022
9efb96a
:potted_plant: clean tests
ishaileshmishra Apr 12, 2022
12f029b
:potted_plant: clean tests
ishaileshmishra Apr 12, 2022
d70169b
:tada: Live Preview
ishaileshmishra Sep 21, 2022
2d70d56
live_preview :trophy:
ishaileshmishra Sep 28, 2022
8778307
query.py live_preview
ishaileshmishra Sep 28, 2022
1b7c208
azure-eu and include_metadata support added
ishaileshmishra May 2, 2023
0333c0b
Merge branch 'master' of https://github.com/contentstack/contentstack…
ishaileshmishra May 2, 2023
d514667
azure-eu and include_metadata support added
ishaileshmishra May 2, 2023
740dfce
feat/CS-37497-azure-eu_and_include_metadata
ishaileshmishra May 4, 2023
84ef3de
azure-eu and include_metadata support added
ishaileshmishra May 4, 2023
1cb1872
- removed print() from tests directory
ishaileshmishra May 4, 2023
08fed21
- removed print() from tests directory
ishaileshmishra May 11, 2023
10d17cd
- removed print() from tests directory
ishaileshmishra May 16, 2023
b2b7eed
Merge pull request #36 from contentstack/feat/CS-38350-live_preview
May 17, 2023
8ffc100
- azure_eu and include_metadata support added
ishaileshmishra May 17, 2023
2b5f7b8
- azure_eu and include_metadata support added
ishaileshmishra May 17, 2023
5592f67
- Azure_eu and include_metadata support added
ishaileshmishra May 23, 2023
d06c8c4
- Azure_eu and include_metadata support added
ishaileshmishra May 23, 2023
e4cc339
- Azure_eu and include_metadata support added
ishaileshmishra May 23, 2023
9ab3dc2
- Azure_eu and include_metadata support added
ishaileshmishra May 23, 2023
22ff561
- Azure_eu and include_metadata support added
ishaileshmishra May 23, 2023
be3cb1b
Merge pull request #40 from contentstack/feat/CS-38762-ci/cd-azure-eu…
May 23, 2023
51a3baf
- Azure_eu and include_metadata support added
ishaileshmishra May 23, 2023
4baebb1
Merge branch 'master' of https://github.com/contentstack/contentstack…
ishaileshmishra May 23, 2023
fcca1c5
Merge branch 'master' into next
ishaileshmishra May 23, 2023
7e5f91b
- Azure_eu and include_metadata support added
ishaileshmishra May 24, 2023
d3cfca8
- Azure_eu and include_metadata support added
ishaileshmishra May 24, 2023
8bbaefe
- Azure_eu and include_metadata support added
ishaileshmishra May 24, 2023
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
39 changes: 39 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
release:
types: [ published ]

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
3 changes: 1 addition & 2 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
threshold: medium

fileignoreconfig:

- filename: README.md
checksum: d9d20b2badbf1aa62649bb174db47a9e491d8687e33ac69fee62568efa23fc56
checksum: b9cad0b376230ea7079fef3459f233b2c61f3d5e48d6d5d03a6bf3e2d39117a8
17 changes: 13 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# CHANGELOG

## _v1.8.0_

### **Date: 26-MAY-2023**

- AZURE_EU, Region support added
- Include Metadata support added to asset, entry and query
- General code improvement clean up
- Updated code for Live Preview

---

## _v1.7.0_
Expand Down Expand Up @@ -67,13 +76,13 @@ Date: 08-Dec-2020
- Timeout support included

- Entry
- added support for include_fallback.
- added support for include_fallback.
- Asset
- added support for include_fallback.
- added support for include_fallback.
- AssetQueryable
- added support for include_fallback.
- added support for include_fallback.
- Query
- added support for include_fallback.
- added support for include_fallback.

---

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2012 - 2021 Contentstack. All rights reserved.
Copyright (c) 2012 - 2023 Contentstack. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
85 changes: 56 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
#

[![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/)
#[![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/)

<!-- ![Python package](https://github.com/contentstack/contentstack-python/workflows/Python%20package/badge.svg?branch=master) -->

![build](https://img.shields.io/badge/build-passing-green?style=plastic)
![Coverage](https://github.com/contentstack/contentstack-python/b4edf799276f586dce3e57fa5502036cd5fd8da3/coverage.svg) ![pip](https://img.shields.io/badge/pip-v1.7.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)
![Coverage](https://github.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)

## Python SDK for Contentstack

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/).
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/).

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.
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.

### Prerequisite

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).
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).

### Setup and Installation

Expand All @@ -29,48 +31,61 @@ pip install contentstack

Install latest [contentstack](https://pypi.org/project/Contentstack) package from the [PyPI](https://pypi.org)

This is the preferred method to install contentstack, as it will always install the most recent stable release. If you don't have [pip](https://pip.pypa.io/) installed, this [Python installation guide](http://docs.python-guide.org/en/latest/starting/installation/) can guide you through the process
This is the preferred method to install contentstack, as it will always install the most recent stable release. If you
don't have [pip](https://pip.pypa.io/) installed,
this [Python installation guide](http://docs.python-guide.org/en/latest/starting/installation/) can guide you through
the process

### Key Concepts for using Contentstack

#### Stack

A stack is like a container that holds the content of your app. Learn more about [Stacks](https://www.contentstack.com/docs/developers/set-up-stack).
A stack is like a container that holds the content of your app. Learn more
about [Stacks](https://www.contentstack.com/docs/developers/set-up-stack).

#### Content Type

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/developers/create-content-types).
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/developers/create-content-types).

#### Entry

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/content-managers/work-with-entries).
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/content-managers/work-with-entries).

#### Asset

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/content-managers/work-with-assets).
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/content-managers/work-with-assets).

#### Environment

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/developers/set-up-environments).
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/developers/set-up-environments).

### Contentstack Python SDK: 5-minute Quickstart

#### Initializing your SDK

To initialize the SDK, specify application API key, access token, and environment name of the stack as shown in the snippet given below, You can provide optional parameters for config:
To initialize the SDK, specify application API key, access token, and environment name of the stack as shown in the
snippet given below, You can provide optional parameters for config:

```python
stack = contentstack.Stack('api_key','delivery_token','environment')
stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
```

To get the API credentials mentioned above, log in to your Contentstack account and then in your top panel navigation, go to Settings &gt; Stack to view the API Key and Access Token.
To get the API credentials mentioned above, log in to your Contentstack account and then in your top panel navigation,
go to Settings &gt; Stack to view the API Key and Access Token.

#### Querying content from your stack

To retrieve a single entry from a content type use the code snippet given below:

```python
stack = contentstack.Stack('api_key','delivery_token','environment')
stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
content_type = stack.content_type("content_type_uid")
entry = content_type.entry("entry_uid")
result = entry.fetch()
Expand All @@ -81,7 +96,7 @@ result = entry.fetch()
To retrieve multiple entries of a particular content type, use the code snippet given below:

```python
stack = contentstack.Stack('api_key','delivery_token','environment')
stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
query = stack.content_type("content_type_uid").query()
result = query.find()
```
Expand All @@ -94,9 +109,12 @@ You can query for content types, entries, assets and more using our Python API R

### Working with Images

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.
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.

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/download?crop=300,400`. There are several more parameters that you can use for your images.
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/download?crop=300,400`. There
are several more parameters that you can use for your images.

[Read Image Delivery API documentation](https://www.contentstack.com/docs/platforms/python/api-reference/).

Expand All @@ -110,13 +128,15 @@ image = stack.image_transform(url, {'auto': 'webp'}).get_url()

### Using the Sync API with Python SDK

The Sync API takes care of syncing your Contentstack data with your application and ensures that the data is always up-to-date by providing delta updates. Contentstack’s Python SDK supports Sync API, which you can use to build powerful applications.
The Sync API takes care of syncing your Contentstack data with your application and ensures that the data is always
up-to-date by providing delta updates. Contentstack’s Python SDK supports Sync API, which you can use to build powerful
applications.

```python
stack = contentstack.Stack('api_key','delivery_token','environment') #initialize sync
response = stack.sync_init() #sycn using sync token
response = stack.sync_token('sync_token') #sycn using pagination token
response = stack.pagination('pagination_token') #sync using multiple parameters
stack = contentstack.Stack('api_key', 'delivery_token', 'environment') # initialize sync
response = stack.sync_init() # sycn using sync token
response = stack.sync_token('sync_token') # sycn using pagination token
response = stack.pagination('pagination_token') # sync using multiple parameters
response = stack.sync_init(publish_type='entry_published', content_type_uid='content_type_uid')
```

Expand All @@ -132,12 +152,19 @@ Read through to understand how to use the Sync API with Contentstack Python SDK.

### The MIT License (MIT)

Copyright © 2012-2021 [Contentstack](https://www.contentstack.com/). All Rights Reserved
Copyright © 2012-2023 [Contentstack](https://www.contentstack.com/). All Rights Reserved

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:
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:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
Software.

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.
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.

- [Content Delivery API Docs](https://contentstack.com/docs/apis/content-delivery-api/)
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Read through to understand how to use the Sync API with Contentstack Python SDK.
The MIT License (MIT)
^^^^^^^^^^^^^^^^^^^^^

Copyright © 2012-2020 Contentstack. All Rights Reserved 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:
Copyright © 2012-2023 Contentstack. All Rights Reserved 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:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

Expand Down
27 changes: 27 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Security

Contentstack takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations.

If you believe you have found a security vulnerability in any Contentstack-owned repository, please report it to us as described below.

## Reporting Security Issues

**Please do not report security vulnerabilities through public GitHub issues.**

Send email to [security@contentstack.com](mailto:security@contentstack.com).

You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message.

Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:

- Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
- Full paths of source file(s) related to the manifestation of the issue
- The location of the affected source code (tag/branch/commit or direct URL)
- Any special configuration required to reproduce the issue
- Step-by-step instructions to reproduce the issue
- Proof-of-concept or exploit code (if possible)
- Impact of the issue, including how an attacker might exploit the issue

This information will help us triage your report more quickly.

[https://www.contentstack.com/trust/](https://www.contentstack.com/trust/)
14 changes: 12 additions & 2 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@
**CHANGELOG**
================

*v1.7.0*
*v1.8.0*
============

**Date: 26-MAY-2023**

- AZURE_EU, Region support added
- Include Metadata support added to asset, entry and query
- General code improvement clean up
- Updated code for Live Preview


*v1.7.0*
============

**Date: 8-APR-2022**
**Date: 08-APR-2022**

Region support added.
- AZURE_NA support added
Expand Down
12 changes: 4 additions & 8 deletions contentstack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
The __init__.py files are required to make Python treat the directories as containing
packages; this is done to prevent directories with a common name, such as string,
from unintentionally hiding valid modules that occur later on the module search path

Used: Safety checks your installed dependencies for known security vulnerabilities
file __init__.py contains package information like
__author__, __status__, __version__, __endpoint__ and __email__

"""
from .entry import Entry
from .asset import Asset
Expand All @@ -16,8 +11,9 @@
from .utility import Utils

__title__ = 'contentstack-python'
__author__ = 'Contentstack'
__author__ = 'contentstack'
__status__ = 'debug'
__version__ = '1.7.0'
__version__ = 'v1.8.0'
__endpoint__ = 'cdn.contentstack.io'
__email__ = 'shailesh.mishra@contentstack.com'
__email__ = 'mobile@contentstack.com'
__developer_email__ = 'shailesh.mishra@contentstack.com'
Loading