Skip to content

Commit 08041bc

Browse files
author
Sebastian Molenda
committed
Introduce limit and next to ListFiles endpoint
1 parent 0c83b72 commit 08041bc

14 files changed

+1292
-543
lines changed

.pubnub.yml

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ sdks:
2424
supported-operating-systems:
2525
Linux:
2626
runtime-version:
27-
- Python 3.7
28-
- Python 3.8
2927
- Python 3.9
3028
- Python 3.10
29+
- Python 3.11
30+
- Python 3.12
31+
- Python 3.13
3132
minimum-os-version:
3233
- Ubuntu 12.04
3334
maximum-os-version:
@@ -37,10 +38,11 @@ sdks:
3738
- x86-64
3839
macOS:
3940
runtime-version:
40-
- Python 3.7
41-
- Python 3.8
4241
- Python 3.9
4342
- Python 3.10
43+
- Python 3.11
44+
- Python 3.12
45+
- Python 3.13
4446
minimum-os-version:
4547
- macOS 10.12
4648
maximum-os-version:
@@ -49,10 +51,11 @@ sdks:
4951
- x86-64
5052
Windows:
5153
runtime-version:
52-
- Python 3.7
53-
- Python 3.8
5454
- Python 3.9
5555
- Python 3.10
56+
- Python 3.11
57+
- Python 3.12
58+
- Python 3.13
5659
minimum-os-version:
5760
- Windows Vista Ultimate
5861
maximum-os-version:
@@ -97,10 +100,11 @@ sdks:
97100
supported-operating-systems:
98101
Linux:
99102
runtime-version:
100-
- Python 3.7
101-
- Python 3.8
102103
- Python 3.9
103104
- Python 3.10
105+
- Python 3.11
106+
- Python 3.12
107+
- Python 3.13
104108
minimum-os-version:
105109
- Ubuntu 12.04
106110
maximum-os-version:
@@ -110,10 +114,11 @@ sdks:
110114
- x86-64
111115
macOS:
112116
runtime-version:
113-
- Python 3.7
114-
- Python 3.8
115117
- Python 3.9
116118
- Python 3.10
119+
- Python 3.11
120+
- Python 3.12
121+
- Python 3.13
117122
minimum-os-version:
118123
- macOS 10.12
119124
maximum-os-version:
@@ -122,10 +127,11 @@ sdks:
122127
- x86-64
123128
Windows:
124129
runtime-version:
125-
- Python 3.7
126-
- Python 3.8
127130
- Python 3.9
128131
- Python 3.10
132+
- Python 3.11
133+
- Python 3.12
134+
- Python 3.13
129135
minimum-os-version:
130136
- Windows Vista Ultimate
131137
maximum-os-version:
@@ -772,19 +778,6 @@ supported-platforms:
772778
- python 3.5.2
773779
- python 3.6.0
774780
- pypy
775-
-
776-
version: PubNub Python Tornado SDK
777-
platforms:
778-
- FreeBSD 8-STABLE or later, amd64, 386
779-
- Linux 2.6 or later, amd64, 386.
780-
- Mac OS X 10.8 or later, amd64
781-
- Windows 7 or later, amd64, 386
782-
editors:
783-
- python 2.7.13
784-
- python 3.4.5
785-
- python 3.5.2
786-
- python 3.6.0
787-
- pypy
788781
-
789782
version: PubNub Python Asyncio SDK
790783
platforms:
@@ -793,12 +786,9 @@ supported-platforms:
793786
- Mac OS X 10.8 or later, amd64
794787
- Windows 7 or later, amd64, 386
795788
editors:
796-
- python 3.4.5
797-
- python 3.5.2
798-
- python 3.6.0
799-
-
800-
version: PubNub Python Twisted SDK
801-
platforms:
802-
- Linux 2.6 or later, amd64, 386.
803-
editors:
804-
- python 2.7.13
789+
- python 3.9.21
790+
- python 3.10.16
791+
- python 3.11.11
792+
- python 3.12.9
793+
- python 3.13.2
794+

pubnub/endpoints/entities/endpoint.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,13 @@ def spaces(self, spaces):
164164
class ListEndpoint:
165165
__metaclass__ = ABCMeta
166166

167-
def __init__(self):
168-
self._limit = None
169-
self._filter = None
170-
self._include_total_count = None
171-
self._sort_keys = None
172-
self._page = None
167+
def __init__(self, limit: int = None, filter: str = None, include_total_count: bool = None,
168+
sort_keys: list = None, page: str = None):
169+
self._limit = limit
170+
self._filter = filter
171+
self._include_total_count = include_total_count
172+
self._sort_keys = sort_keys
173+
self._page = page
173174

174175
def limit(self, limit):
175176
self._limit = int(limit)

pubnub/endpoints/file_operations/list_files.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,43 @@ class PNGetFilesResultEnvelope(Envelope):
1414
class ListFiles(FileOperationEndpoint):
1515
LIST_FILES_URL = "/v1/files/%s/channels/%s/files"
1616
_channel: str
17+
_limit: int
18+
_next: str
1719

18-
def __init__(self, pubnub, channel: str = None):
20+
def __init__(self, pubnub, channel: str = None, *, limit: int = None, next: str = None):
1921
FileOperationEndpoint.__init__(self, pubnub)
2022
self._channel = channel
23+
self._limit = limit
24+
self._next = next
2125

2226
def build_path(self):
2327
return ListFiles.LIST_FILES_URL % (
2428
self.pubnub.config.subscribe_key,
2529
utils.url_encode(self._channel)
2630
)
2731

28-
def channel(self, channel) -> 'ListFiles':
32+
def channel(self, channel: str) -> 'ListFiles':
2933
self._channel = channel
3034
return self
3135

36+
def limit(self, limit: int) -> 'ListFiles':
37+
self._limit = limit
38+
return self
39+
40+
def next(self, next: str) -> 'ListFiles':
41+
self._next = next
42+
return self
43+
3244
def http_method(self):
3345
return HttpMethod.GET
3446

3547
def custom_params(self):
36-
return {}
48+
params = {}
49+
if self._limit:
50+
params["limit"] = str(self._limit)
51+
if self._next:
52+
params["next"] = str(self._next)
53+
return params
3754

3855
def is_auth_required(self):
3956
return True

pubnub/models/consumer/file.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ def __init__(self, result):
33
self.data = result['data']
44
self.count = result.get('count', None)
55
self.next = result.get('next', None)
6-
self.prev = result.get('prev', None)
76

87
def __str__(self):
98
return "Get files success with data: %s" % self.data

pubnub/pubnub_core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,8 @@ def download_file(self):
466466
else:
467467
raise NotImplementedError
468468

469-
def list_files(self, channel: str = None) -> ListFiles:
470-
return ListFiles(self, channel=channel)
469+
def list_files(self, channel: str = None, *, limit: int = None, next: str = None) -> ListFiles:
470+
return ListFiles(self, channel=channel, limit=limit, next=next)
471471

472472
def get_file_url(self, channel: str = None, file_name: str = None, file_id: str = None) -> GetFileDownloadUrl:
473473
return GetFileDownloadUrl(self, channel=channel, file_name=file_name, file_id=file_id)

0 commit comments

Comments
 (0)