Skip to content

Commit 5d31570

Browse files
Merge pull request #8 from contentstack/1.0.0
1.0.0 release
2 parents eee94b1 + ef2d8ce commit 5d31570

21 files changed

+987
-662
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ name: Python package
55

66
on:
77
push:
8-
branches: [ 1.0.0 ]
8+
branches: [ master, 1.0.0 ]
99
pull_request:
10-
branches: [ 1.0.0 ]
10+
branches: [ master, 1.0.0 ]
1111

1212
jobs:
1313
build:
1414

1515
runs-on: ubuntu-latest
1616
strategy:
1717
matrix:
18-
python-version: [3.5, 3.6, 3.7, 3.8]
18+
python-version: [3.6, 3.7, 3.8]
1919

2020
steps:
2121
- uses: actions/checkout@v2

.gitignore

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

66
# C extensions
77
*.so
8-
8+
/reports
9+
/tests/reports
910
# Distribution / packaging
1011
.Python
1112
build/
@@ -26,6 +27,10 @@ wheels/
2627
MANIFEST
2728
*.DS_Store
2829
*.DS_Store?
30+
.pytest_cache
31+
.idea
32+
.vscode
33+
.report.log
2934

3035
# PyInstaller
3136
# Usually these files are written by a python script from a template

CHANGELOGS.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,37 @@
1+
CHANGELOG
2+
=============
13

4+
*Date: 17-Jun-2020 - initial release*
5+
6+
**v1.0.0**
7+
============
8+
9+
- **Stack**
10+
- Initialisation of stack has been modified
11+
- External config support moved to stack initialisation optional paramters
12+
- Added support for whereIn(String key) and whereNotIn(String key) methods in Query
13+
14+
- **Assets**
15+
- changes incorporated in Asset class.
16+
17+
- **Entry**
18+
- changes incorporated in the entry class.
19+
20+
- **Query**
21+
- Changes incorporated in the Query class.
22+
23+
24+
-----------------------------
25+
26+
*Date: 18-Nov-2019 - beta release*
27+
28+
**v0.0.1**
29+
============
30+
- Beta release for the contentstack-python SDK for Content Delivery API
31+
=======
232
## Version 0.1.0
333
##### November-18, 2019 -beta release
434

535
### Initial release for the contentstack-python-sdk for Content Delivery API
636

7-
837
-----------------------------

INSTALL

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
To install the package simply run the below command on your terminal:
3+
4+
python setup.py install
5+
6+
Don't forget to file bugs and let me know about them.
7+
Also, don't hasitate to ask for new features. Happy coding.

changelog.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
=========
2+
CHANGELOG
3+
=========
4+
5+
*Date: 17-Jun-2020 - initial release*
6+
7+
**v1.0.0**
8+
============
9+
10+
- **Stack**
11+
- Initialisation of stack has been modified
12+
- External config support moved to stack initialisation optional paramters
13+
- Added support for whereIn(String key) and whereNotIn(String key) methods in Query
14+
15+
- **Asset**
16+
- changes incorporated in Asset class.
17+
18+
- **Entry**
19+
- changes incorporated in the entry class.
20+
21+
- **Query**
22+
- Changes incorporated in the Query class.
23+
24+
25+
-----------------------------
26+
27+
*Date: 18-Nov-2019 - beta release*
28+
29+
**v0.0.1**
30+
============
31+
- Beta release for the contentstack-python SDK for Content Delivery API

contentstack/__init__.py

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
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-
181
from .entry import Entry
192
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
3+
from .contenttype import ContentType
4+
from .https_connection import HTTPSConnection
245
from .stack import Stack
6+
from .utility import Utils
7+
# from contentstack import *
258

26-
import logging
27-
from logging import NullHandler
28-
logging.getLogger(__name__).addHandler(NullHandler())
29-
warnings.simplefilter('default', FileModeWarning, append=True)
9+
__author__ = 'Contentstack'
10+
__status__ = 'debug'
11+
__version__ = '1.0.0'
12+
__endpoint__ = 'cdn.contentstack.io'
13+
__email__ = 'mshaileshr@gmail.com'

contentstack/assetquery.py

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
r"""This call fetches the list of all the assets of a particular stack.
2+
It also returns the content of each asset in JSON format.
3+
You can also specify the environment of which you wish to get the assets.
4+
"""
5+
6+
# ************* Module assetquery **************
7+
# Your code has been rated at 10/10 by pylint
8+
9+
import json
10+
from contentstack.utility import Utils
11+
from contentstack.basequery import BaseQuery
12+
13+
14+
class AssetQuery(BaseQuery):
15+
"""
16+
This call fetches the list of all the assets of a particular stack.
17+
"""
18+
19+
def __init__(self, http_instance):
20+
super().__init__()
21+
self.http_instance = http_instance
22+
self.__query_params = {}
23+
self.base_url = "{}/assets".format(self.http_instance.endpoint)
24+
if "environment" in self.http_instance.headers:
25+
env = self.http_instance.headers["environment"]
26+
self.base_url = "{}?{}".format(self.base_url, "environment={}".format(env))
27+
28+
def environment(self, environment):
29+
r"""Provide the name of the environment if you wish to retrieve the assets published
30+
in a particular environment.
31+
32+
:param environment: environment of the stack
33+
34+
:return: AssetQuery - so we can chain the call
35+
36+
-----------------------------
37+
[Example]:
38+
39+
>>> import contentstack
40+
>>> stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
41+
>>> result = stack.asset_query().environment('production').find()
42+
------------------------------
43+
"""
44+
self.__query_params["environment"] = environment
45+
return self
46+
47+
def version(self, version):
48+
r"""Specify the version number of the asset that you wish to retrieve.
49+
If the version is not specified, the details of the latest version will be retrieved.
50+
To retrieve a specific version, keep the environment parameter blank.
51+
52+
:param version: version number of the asset that you wish to retrieve
53+
54+
:return: AssetQuery: so we can chain the call
55+
56+
-----------------------------
57+
[Example]:
58+
59+
>>> import contentstack
60+
>>> stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
61+
>>> result = stack.asset_query().version(3).find()
62+
------------------------------
63+
"""
64+
self.__query_params["version"] = version
65+
return self
66+
67+
def include_dimension(self):
68+
r"""Include the dimensions (height and width) of the image in the response.
69+
Supported image types: JPG, GIF, PNG, WebP, BMP, TIFF, SVG, and PSD
70+
71+
:return: AssetQuery: so we can chain the call
72+
73+
-----------------------------
74+
[Example]:
75+
76+
>>> import contentstack
77+
>>> stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
78+
>>> result = stack.asset_query().include_dimension().find()
79+
------------------------------
80+
"""
81+
self.__query_params["include_dimension"] = "true"
82+
return self
83+
84+
def relative_url(self):
85+
r"""include the relative URLs of the assets in the response.
86+
87+
:return: AssetQuery: so we can chain the call
88+
89+
-----------------------------
90+
[Example]:
91+
92+
>>> import contentstack
93+
>>> stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
94+
>>> result = stack.asset_query().relative_url().find()
95+
------------------------------
96+
"""
97+
self.__query_params["relative_urls"] = "true"
98+
return self
99+
100+
def find(self):
101+
r"""This call fetches the list of all the assets of a particular stack.
102+
It also returns the content of each asset in JSON format.
103+
Learn more about Assets
104+
[https://www.contentstack.com/docs/content-managers/work-with-assets].
105+
106+
:return: json result, List of asset object
107+
108+
-----------------------------
109+
[Example]:
110+
111+
>>> import contentstack
112+
>>> stack = contentstack.Stack('api_key', 'delivery_token', 'environment')
113+
>>> result = stack.asset_query().find()
114+
115+
"""
116+
if self.parameters is not None and len(self.parameters) > 0:
117+
self.__query_params["query"] = json.dumps(self.parameters)
118+
url = Utils.get_complete_url(self.base_url, self.__query_params)
119+
return self.http_instance.get(url)

0 commit comments

Comments
 (0)