Skip to content
This repository was archived by the owner on Mar 6, 2024. It is now read-only.

Commit e900911

Browse files
authored
For api 35.0+, single encode query filter, and remove filterEncoded param (#710)
vCD zeus will no longer accept double encoded filter value as part of query api. To accommodate the shift in behavior, pyvcloud will no longer double encode the query filter string and won't send in the filterEncoded param for api v35.0+. However the values in qfilter param to get_typed_query should still be encoded, the responsibility lies with the caller. The equality_filter's value will continue to be encoded by pyvcloud.
1 parent 4ec9edd commit e900911

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

pyvcloud/vcd/client.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,7 +1835,10 @@ def __init__(self,
18351835
self._filter = ''
18361836
self._filter += equality_filter[0]
18371837
self._filter += '=='
1838-
self._filter += equality_filter[1]
1838+
if float(client.get_api_version()) < float(ApiVersion.VERSION_35.value): # noqa: E501
1839+
self._filter += equality_filter[1]
1840+
else:
1841+
self._filter += urllib.parse.quote(equality_filter[1])
18391842

18401843
self._sort_desc = sort_desc
18411844
self._sort_asc = sort_asc
@@ -1914,14 +1917,20 @@ def _build_query_uri(self,
19141917
uri += '&pageSize='
19151918
uri += str(page_size)
19161919

1917-
if qfilter is not None:
1918-
# filterEncoded=true directs vCD to decode the individual filter
1919-
# values, i.e. the value after each ==.
1920-
uri += '&filterEncoded=true&filter='
1921-
# Need to encode the value of filter param again to escape special
1922-
# characters like ',', ';' which have special meaning in context of
1923-
# query filter.
1924-
uri += urllib.parse.quote(qfilter)
1920+
if qfilter:
1921+
if float(self._client.get_api_version()) < float(ApiVersion.VERSION_35.value): # noqa: E501
1922+
# filterEncoded=true directs vCD to decode the individual
1923+
# filter values, i.e. the value after each ==.
1924+
uri += '&filterEncoded=true&filter='
1925+
# Need to encode the value of filter param again to escape
1926+
# special characters like ',', ';' which have special meaning
1927+
# in context of query filter.
1928+
uri += urllib.parse.quote(qfilter)
1929+
else:
1930+
# api v35.0 (vCD Zeus) onwards vCD doesn't accept double
1931+
# encoded filter values, neither the filterEncoded query param
1932+
# has any effect
1933+
uri += f"&filter={qfilter}"
19251934

19261935
if fields is not None:
19271936
uri += '&fields='

0 commit comments

Comments
 (0)