Skip to content

Commit ece036a

Browse files
committed
Fix gitea_api.SSHKey.list() to use pagination instead of limit -1
1 parent 775d0c2 commit ece036a

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

osc/gitea_api/ssh_key.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
from typing import List
22
from typing import Optional
33

4+
from .common import GiteaModel
45
from .connection import Connection
56
from .connection import GiteaHTTPResponse
67

78

8-
class SSHKey:
9-
def __init__(self, data: dict, *, response: Optional[GiteaHTTPResponse] = None):
10-
self._data = data
11-
self._response = response
12-
9+
class SSHKey(GiteaModel):
1310
@property
1411
def id(self) -> int:
1512
return self._data["id"]
@@ -43,11 +40,13 @@ def list(cls, conn: Connection) -> List["SSHKey"]:
4340
:param conn: Gitea ``Connection`` instance.
4441
"""
4542
q = {
46-
"limit": -1,
43+
"limit": 50,
4744
}
4845
url = conn.makeurl("user", "keys", query=q)
4946
response = conn.request("GET", url)
50-
obj_list = [cls(i, response=response) for i in response.json()]
47+
obj_list = []
48+
for response in conn.request_all_pages("GET", url):
49+
obj_list.extend([cls(i, response=response, conn=conn) for i in response.json() or []])
5150
return obj_list
5251

5352
@classmethod

0 commit comments

Comments
 (0)