Skip to content

Commit ffb302f

Browse files
authored
Merge pull request #84 from contentstack/next
Fetch Asset by query
2 parents c1825a6 + f099814 commit ffb302f

File tree

6 files changed

+32
-16
lines changed

6 files changed

+32
-16
lines changed

.github/workflows/sca-scan.yml

+1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ jobs:
1111
uses: snyk/actions/python@master
1212
env:
1313
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
14+
SNYK_INTEGRATION_VERSION: python-3.11
1415
with:
1516
args: --fail-on=all --all-projects --skip-unresolved

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# CHANGELOG
22

3+
4+
## _v1.10.0_
5+
6+
### **Date: 03-SEPTEMBER-2024**
7+
8+
- Fetch asset by any other field than UID
9+
310
## _v1.9.0_
411

512
### **Date: 14-MAY-2024**

contentstack/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
__title__ = 'contentstack-delivery-python'
2323
__author__ = 'contentstack'
2424
__status__ = 'debug'
25-
__version__ = 'v1.9.0'
25+
__version__ = 'v1.10.0'
2626
__endpoint__ = 'cdn.contentstack.io'
2727
__email__ = '[email protected]'
2828
__developer_email__ = '[email protected]'

contentstack/assetquery.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,6 @@ def find(self):
176176
177177
"""
178178
if self.parameters is not None and len(self.parameters) > 0:
179-
self.asset_query_params["query"] = json.dumps(self.parameters)
179+
self.asset_query_params["query"] = self.parameters
180180
url = Utils.get_complete_url(self.base_url, self.asset_query_params)
181181
return self.http_instance.get(url)

contentstack/utility.py

+17-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import json
77
import logging
8-
from urllib import parse
8+
from urllib.parse import urlencode, urljoin
99

1010
log = logging.getLogger(__name__)
1111

@@ -55,14 +55,22 @@ def do_url_encode(params):
5555
return parse.urlencode(params)
5656

5757
@staticmethod
58-
def get_complete_url(base_url: str, params: dict):
58+
def get_complete_url(base_url: str, params: dict) -> str:
5959
"""
60-
creates complete url using base_url and their respective parameters
61-
:param base_url:
62-
:param params:
63-
:return:
60+
Creates a complete URL using base_url and their respective parameters.
61+
:param base_url: The base URL to which parameters are appended.
62+
:param params: A dictionary of parameters to be included in the URL.
63+
:return: A complete URL with encoded parameters.
6464
"""
65+
# Ensure 'query' is properly serialized as a JSON string without extra quotes
6566
if 'query' in params:
66-
params["query"] = json.dumps(params["query"])
67-
query = parse.urlencode(params)
68-
return f'{base_url}&{query}'
67+
params["query"] = json.dumps(params["query"], separators=(',', ':'))
68+
69+
# Encode parameters
70+
query_string = urlencode(params, doseq=True)
71+
72+
# Join base_url and query_string
73+
if '?' in base_url:
74+
return f'{base_url}&{query_string}'
75+
else:
76+
return f'{base_url}?{query_string}'

requirements.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
twython==3.9.1
2-
setuptools==67.8.0
2+
setuptools~=74.0.0
33
contentstack-utils==1.3.0
44
python-dateutil==2.8.2
5-
requests==2.31.0
5+
requests==2.32.2
66
coverage==7.2.6
77
tox==4.5.1
88
virtualenv==20.23.0
@@ -49,15 +49,15 @@ imagesize==1.4.1
4949
snowballstemmer~=2.2.0
5050
Pygments~=2.15.1
5151
wrapt==1.15.0
52-
certifi==2024.2.2
52+
certifi==2024.7.4
5353
oauthlib==3.2.2
5454
idna==3.7
5555
chardet~=5.2.0
5656
alabaster==0.7.13
57-
zipp==3.15.0
57+
zipp==3.19.1
5858
distlib~=0.3.6
5959
cachetools~=5.3.0
6060
tomlkit~=0.11.8
61-
urllib3==2.0.7
61+
urllib3==2.2.2
6262
exceptiongroup~=1.1.1
6363
iniconfig~=2.0.0

0 commit comments

Comments
 (0)