python-gerrit-api 2.1.8__tar.gz → 2.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. {python-gerrit-api-2.1.8/python_gerrit_api.egg-info → python_gerrit_api-2.2.0}/PKG-INFO +4 -2
  2. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/README.rst +1 -1
  3. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/__init__.py +32 -52
  4. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/accounts/account.py +70 -33
  5. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/accounts/accounts.py +9 -6
  6. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/accounts/emails.py +10 -6
  7. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/accounts/gpg_keys.py +11 -7
  8. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/accounts/ssh_keys.py +16 -9
  9. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/changes/change.py +84 -52
  10. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/changes/changes.py +4 -2
  11. {python-gerrit-api-2.1.8/gerrit/changes/revision → python_gerrit_api-2.2.0/gerrit/changes}/comments.py +8 -3
  12. {python-gerrit-api-2.1.8/gerrit/changes/revision → python_gerrit_api-2.2.0/gerrit/changes}/drafts.py +9 -3
  13. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/changes/edit.py +17 -8
  14. {python-gerrit-api-2.1.8/gerrit/changes/revision → python_gerrit_api-2.2.0/gerrit/changes}/files.py +8 -3
  15. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/changes/messages.py +8 -3
  16. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/changes/reviewers.py +17 -7
  17. python-gerrit-api-2.1.8/gerrit/changes/revision/__init__.py → python_gerrit_api-2.2.0/gerrit/changes/revision.py +32 -20
  18. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/config/caches.py +5 -3
  19. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/config/config.py +19 -6
  20. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/config/tasks.py +2 -2
  21. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/gitiles/__init__.py +4 -1
  22. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/groups/group.py +10 -4
  23. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/groups/groups.py +9 -5
  24. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/groups/members.py +4 -6
  25. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/groups/subgroups.py +4 -6
  26. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/plugins/plugins.py +9 -4
  27. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/projects/branches.py +13 -5
  28. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/projects/commit.py +4 -1
  29. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/projects/dashboards.py +11 -4
  30. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/projects/labels.py +5 -2
  31. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/projects/project.py +39 -22
  32. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/projects/projects.py +17 -7
  33. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/projects/tags.py +13 -7
  34. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/projects/webhooks.py +10 -5
  35. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/utils/common.py +47 -8
  36. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/utils/entity.py +8 -4
  37. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/utils/models.py +4 -1
  38. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/utils/requester.py +35 -36
  39. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0/python_gerrit_api.egg-info}/PKG-INFO +4 -2
  40. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/python_gerrit_api.egg-info/SOURCES.txt +4 -4
  41. python_gerrit_api-2.2.0/python_gerrit_api.egg-info/requires.txt +1 -0
  42. python_gerrit_api-2.2.0/requirements.txt +1 -0
  43. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/setup.py +1 -0
  44. python_gerrit_api-2.2.0/tests/test_accounts.py +283 -0
  45. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/tests/test_changes.py +2 -2
  46. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/tests/test_groups.py +6 -2
  47. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/tests/test_projects.py +9 -8
  48. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/tests/test_revision.py +2 -2
  49. python-gerrit-api-2.1.8/python_gerrit_api.egg-info/requires.txt +0 -2
  50. python-gerrit-api-2.1.8/requirements.txt +0 -2
  51. python-gerrit-api-2.1.8/tests/test_accounts.py +0 -138
  52. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/LICENSE +0 -0
  53. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/MANIFEST.in +0 -0
  54. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/accounts/__init__.py +0 -0
  55. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/changes/__init__.py +0 -0
  56. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/config/__init__.py +0 -0
  57. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/groups/__init__.py +0 -0
  58. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/plugins/__init__.py +0 -0
  59. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/projects/__init__.py +0 -0
  60. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/utils/__init__.py +0 -0
  61. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/gerrit/utils/exceptions.py +0 -0
  62. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/python_gerrit_api.egg-info/dependency_links.txt +0 -0
  63. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/python_gerrit_api.egg-info/top_level.txt +0 -0
  64. {python-gerrit-api-2.1.8 → python_gerrit_api-2.2.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-gerrit-api
3
- Version: 2.1.8
3
+ Version: 2.2.0
4
4
  Summary: Python wrapper for the Gerrit REST API.
5
5
  Home-page: https://github.com/shijl0925/python-gerrit-api
6
6
  Author: Jialiang Shi
@@ -18,8 +18,10 @@ Classifier: Programming Language :: Python :: 3.8
18
18
  Classifier: Programming Language :: Python :: 3.9
19
19
  Classifier: Programming Language :: Python :: 3.10
20
20
  Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
21
22
  Classifier: Topic :: Software Development
22
23
  License-File: LICENSE
24
+ Requires-Dist: requests
23
25
 
24
26
  Project description
25
27
  ===================
@@ -28,7 +30,7 @@ Project description
28
30
  :target: https://pypi.python.org/pypi/python-gerrit-api
29
31
  .. image:: https://img.shields.io/pypi/v/python-gerrit-api.svg
30
32
  :target: https://pypi.python.org/pypi/python-gerrit-api
31
- .. image:: https://pepy.tech/badge/python-gerrit-api
33
+ .. image:: https://static.pepy.tech/badge/python-gerrit-api
32
34
  :target: https://pepy.tech/project/python-gerrit-api
33
35
  .. image:: https://sonarcloud.io/api/project_badges/measure?project=shijl0925_python-gerrit-api&metric=alert_status
34
36
  :target: https://sonarcloud.io/dashboard?id=shijl0925_python-gerrit-api
@@ -5,7 +5,7 @@ Project description
5
5
  :target: https://pypi.python.org/pypi/python-gerrit-api
6
6
  .. image:: https://img.shields.io/pypi/v/python-gerrit-api.svg
7
7
  :target: https://pypi.python.org/pypi/python-gerrit-api
8
- .. image:: https://pepy.tech/badge/python-gerrit-api
8
+ .. image:: https://static.pepy.tech/badge/python-gerrit-api
9
9
  :target: https://pepy.tech/project/python-gerrit-api
10
10
  .. image:: https://sonarcloud.io/api/project_badges/measure?project=shijl0925_python-gerrit-api&metric=alert_status
11
11
  :target: https://sonarcloud.io/dashboard?id=shijl0925_python-gerrit-api
@@ -1,11 +1,13 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  # @Author: Jialiang Shi
4
- __version__ = "2.1.8"
4
+ __version__ = "2.2.0"
5
5
 
6
- import json
7
6
  import netrc
7
+ import requests
8
+ from requests.adapters import HTTPAdapter
8
9
  from gerrit.utils.requester import Requester
10
+ from gerrit.utils.common import decode_response, strip_trailing_slash
9
11
  from gerrit.config.config import GerritConfig
10
12
  from gerrit.projects.projects import GerritProjects
11
13
  from gerrit.accounts.accounts import GerritAccounts
@@ -33,21 +35,35 @@ class GerritClient(object):
33
35
  cert=None,
34
36
  timeout=60,
35
37
  max_retries=None,
36
- auth_suffix="/a"
38
+ auth_suffix="/a",
37
39
  ):
38
- self._base_url = self.strip_trailing_slash(base_url)
40
+ self._base_url = strip_trailing_slash(base_url)
39
41
 
40
42
  if use_netrc:
41
43
  password = self.get_password_from_netrc_file()
42
44
 
45
+ # make request session
46
+ _session = requests.Session()
47
+ if username and password:
48
+ _session.auth = (username, password)
49
+
50
+ if ssl_verify:
51
+ _session.verify = ssl_verify
52
+
53
+ if cert is not None:
54
+ _session.cert = cert
55
+
56
+ if max_retries is not None:
57
+ retry_adapter = HTTPAdapter(max_retries=max_retries)
58
+ _session.mount("http://", retry_adapter)
59
+ _session.mount("https://", retry_adapter)
60
+
61
+ self.session = _session
62
+
43
63
  self.requester = Requester(
44
64
  base_url=base_url,
45
- username=username,
46
- password=password,
47
- ssl_verify=ssl_verify,
48
- cert=cert,
65
+ session=self.session,
49
66
  timeout=timeout,
50
- max_retries=max_retries,
51
67
  )
52
68
  if username and password:
53
69
  self.auth_suffix = auth_suffix
@@ -63,20 +79,11 @@ class GerritClient(object):
63
79
  netrc_client = netrc.netrc()
64
80
  auth_tokens = netrc_client.authenticators(self._base_url)
65
81
  if not auth_tokens:
66
- raise ValueError(f"The '{self._base_url}' host name is not found in netrc file.")
82
+ raise ValueError(
83
+ f"The '{self._base_url}' host name is not found in netrc file."
84
+ )
67
85
  return auth_tokens[2]
68
86
 
69
- @classmethod
70
- def strip_trailing_slash(cls, url):
71
- """
72
- remove url's trailing slash
73
- :param url: url
74
- :return:
75
- """
76
- while url.endswith("/"):
77
- url = url[:-1]
78
- return url
79
-
80
87
  def get_endpoint_url(self, endpoint):
81
88
  """
82
89
  Return the complete url including host and port for a given endpoint.
@@ -85,33 +92,6 @@ class GerritClient(object):
85
92
  """
86
93
  return f"{self._base_url}{self.auth_suffix}{endpoint}"
87
94
 
88
- @staticmethod
89
- def decode_response(response):
90
- """Strip off Gerrit's magic prefix and decode a response.
91
- :returns:
92
- Decoded JSON content as a dict, or raw text if content could not be
93
- decoded as JSON.
94
- :raises:
95
- requests.HTTPError if the response contains an HTTP error status code.
96
- """
97
- magic_json_prefix = ")]}'\n"
98
- content_type = response.headers.get("content-type", "")
99
-
100
- content = response.content.strip()
101
- if response.encoding:
102
- content = content.decode(response.encoding)
103
- if not content:
104
- return content
105
- if content_type.split(";")[0] != "application/json":
106
- return content
107
- if content.startswith(magic_json_prefix):
108
- index = len(magic_json_prefix)
109
- content = content[index:]
110
- try:
111
- return json.loads(content)
112
- except ValueError:
113
- raise ValueError(f"Invalid json content: {content}")
114
-
115
95
  @property
116
96
  def config(self):
117
97
  """
@@ -196,7 +176,7 @@ class GerritClient(object):
196
176
  :return:
197
177
  """
198
178
  response = self.requester.get(self.get_endpoint_url(endpoint), **kwargs)
199
- result = self.decode_response(response)
179
+ result = decode_response(response)
200
180
  return result
201
181
 
202
182
  def post(self, endpoint, **kwargs):
@@ -207,7 +187,7 @@ class GerritClient(object):
207
187
  :return:
208
188
  """
209
189
  response = self.requester.post(self.get_endpoint_url(endpoint), **kwargs)
210
- result = self.decode_response(response)
190
+ result = decode_response(response)
211
191
  return result
212
192
 
213
193
  def put(self, endpoint, **kwargs):
@@ -218,7 +198,7 @@ class GerritClient(object):
218
198
  :return:
219
199
  """
220
200
  response = self.requester.put(self.get_endpoint_url(endpoint), **kwargs)
221
- result = self.decode_response(response)
201
+ result = decode_response(response)
222
202
  return result
223
203
 
224
204
  def delete(self, endpoint):
@@ -228,4 +208,4 @@ class GerritClient(object):
228
208
  :param endpoint: The endpoint to send to.
229
209
  :return:
230
210
  """
231
- self.requester.delete(self.get_endpoint_url(endpoint))
211
+ self.requester.delete(self.get_endpoint_url(endpoint))
@@ -11,7 +11,7 @@ class GerritAccount(BaseModel):
11
11
  def __init__(self, **kwargs):
12
12
  super().__init__(**kwargs)
13
13
  self.entity_name = "username"
14
- self.endpoint = f"/accounts/{self.username}"
14
+ self.endpoint = f"/accounts/{self.account_id}"
15
15
 
16
16
  def get_name(self):
17
17
  """
@@ -41,8 +41,9 @@ class GerritAccount(BaseModel):
41
41
  https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#account-name-input
42
42
  :return:
43
43
  """
44
- return self.gerrit.put(self.endpoint + "/name",
45
- json=input_, headers=self.gerrit.default_headers)
44
+ return self.gerrit.put(
45
+ self.endpoint + "/name", json=input_, headers=self.gerrit.default_headers
46
+ )
46
47
 
47
48
  def delete_name(self):
48
49
  """
@@ -74,8 +75,9 @@ class GerritAccount(BaseModel):
74
75
  :return:
75
76
  """
76
77
  input_ = {"status": status}
77
- return self.gerrit.put(self.endpoint + "/status",
78
- json=input_, headers=self.gerrit.default_headers)
78
+ return self.gerrit.put(
79
+ self.endpoint + "/status", json=input_, headers=self.gerrit.default_headers
80
+ )
79
81
 
80
82
  def set_username(self, input_):
81
83
  """
@@ -96,8 +98,11 @@ class GerritAccount(BaseModel):
96
98
  https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#username-input
97
99
  :return:
98
100
  """
99
- return self.gerrit.put(self.endpoint + "/username",
100
- json=input_, headers=self.gerrit.default_headers)
101
+ return self.gerrit.put(
102
+ self.endpoint + "/username",
103
+ json=input_,
104
+ headers=self.gerrit.default_headers,
105
+ )
101
106
 
102
107
  def set_displayname(self, input_):
103
108
  """
@@ -117,8 +122,11 @@ class GerritAccount(BaseModel):
117
122
  https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#display-name-input
118
123
  :return:
119
124
  """
120
- return self.gerrit.put(self.endpoint + "/displayname",
121
- json=input_, headers=self.gerrit.default_headers)
125
+ return self.gerrit.put(
126
+ self.endpoint + "/displayname",
127
+ json=input_,
128
+ headers=self.gerrit.default_headers,
129
+ )
122
130
 
123
131
  def get_active(self):
124
132
  """
@@ -163,8 +171,11 @@ class GerritAccount(BaseModel):
163
171
  https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#http-password-input
164
172
  :return:
165
173
  """
166
- return self.gerrit.put(self.endpoint + "/password.http",
167
- json=input_, headers=self.gerrit.default_headers)
174
+ return self.gerrit.put(
175
+ self.endpoint + "/password.http",
176
+ json=input_,
177
+ headers=self.gerrit.default_headers,
178
+ )
168
179
 
169
180
  def delete_http_password(self):
170
181
  """
@@ -187,15 +198,15 @@ class GerritAccount(BaseModel):
187
198
 
188
199
  @property
189
200
  def emails(self):
190
- return GerritAccountEmails(username=self.username, gerrit=self.gerrit)
201
+ return GerritAccountEmails(account_id=self.account_id, gerrit=self.gerrit)
191
202
 
192
203
  @property
193
204
  def ssh_keys(self):
194
- return GerritAccountSSHKeys(username=self.username, gerrit=self.gerrit)
205
+ return GerritAccountSSHKeys(account_id=self.account_id, gerrit=self.gerrit)
195
206
 
196
207
  @property
197
208
  def gpg_keys(self):
198
- return GerritAccountGPGKeys(username=self.username, gerrit=self.gerrit)
209
+ return GerritAccountGPGKeys(account_id=self.account_id, gerrit=self.gerrit)
199
210
 
200
211
  def list_capabilities(self):
201
212
  """
@@ -275,8 +286,11 @@ class GerritAccount(BaseModel):
275
286
  https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#preferences-input
276
287
  :return:
277
288
  """
278
- return self.gerrit.put(self.endpoint + "/preferences",
279
- json=input_, headers=self.gerrit.default_headers)
289
+ return self.gerrit.put(
290
+ self.endpoint + "/preferences",
291
+ json=input_,
292
+ headers=self.gerrit.default_headers,
293
+ )
280
294
 
281
295
  def get_diff_preferences(self):
282
296
  """
@@ -314,8 +328,11 @@ class GerritAccount(BaseModel):
314
328
  https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#diff-preferences-input
315
329
  :return:
316
330
  """
317
- return self.gerrit.put(self.endpoint + "/preferences.diff",
318
- json=input_, headers=self.gerrit.default_headers)
331
+ return self.gerrit.put(
332
+ self.endpoint + "/preferences.diff",
333
+ json=input_,
334
+ headers=self.gerrit.default_headers,
335
+ )
319
336
 
320
337
  def get_edit_preferences(self):
321
338
  """
@@ -355,8 +372,11 @@ class GerritAccount(BaseModel):
355
372
  https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#edit-preferences-info
356
373
  :return:
357
374
  """
358
- return self.gerrit.put(self.endpoint + "/preferences.edit",
359
- json=input_, headers=self.gerrit.default_headers)
375
+ return self.gerrit.put(
376
+ self.endpoint + "/preferences.edit",
377
+ json=input_,
378
+ headers=self.gerrit.default_headers,
379
+ )
360
380
 
361
381
  def get_watched_projects(self):
362
382
  """
@@ -388,8 +408,11 @@ class GerritAccount(BaseModel):
388
408
  :param input_: the ProjectWatchInfo entities as list
389
409
  :return:
390
410
  """
391
- return self.gerrit.post(self.endpoint + "/watched.projects",
392
- json=input_, headers=self.gerrit.default_headers)
411
+ return self.gerrit.post(
412
+ self.endpoint + "/watched.projects",
413
+ json=input_,
414
+ headers=self.gerrit.default_headers,
415
+ )
393
416
 
394
417
  def delete_watched_projects(self, input_):
395
418
  """
@@ -410,8 +433,11 @@ class GerritAccount(BaseModel):
410
433
  :param input_: the watched projects as list
411
434
  :return:
412
435
  """
413
- self.gerrit.post(self.endpoint + "/watched.projects:delete",
414
- json=input_, headers=self.gerrit.default_headers)
436
+ self.gerrit.post(
437
+ self.endpoint + "/watched.projects:delete",
438
+ json=input_,
439
+ headers=self.gerrit.default_headers,
440
+ )
415
441
 
416
442
  def get_external_ids(self):
417
443
  """
@@ -442,8 +468,11 @@ class GerritAccount(BaseModel):
442
468
  :param input_: the external ids as list
443
469
  :return:
444
470
  """
445
- self.gerrit.post(self.endpoint + "/external.ids:delete",
446
- json=input_, headers=self.gerrit.default_headers)
471
+ self.gerrit.post(
472
+ self.endpoint + "/external.ids:delete",
473
+ json=input_,
474
+ headers=self.gerrit.default_headers,
475
+ )
447
476
 
448
477
  def list_contributor_agreements(self):
449
478
  """
@@ -469,9 +498,11 @@ class GerritAccount(BaseModel):
469
498
  https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#contributor-agreement-input
470
499
  :return:
471
500
  """
472
- return self.gerrit.put(self.endpoint + "/agreements",
473
- json=input_, headers=self.gerrit.default_headers)
474
-
501
+ return self.gerrit.put(
502
+ self.endpoint + "/agreements",
503
+ json=input_,
504
+ headers=self.gerrit.default_headers,
505
+ )
475
506
 
476
507
  def delete_draft_comments(self, input_):
477
508
  """
@@ -489,8 +520,11 @@ class GerritAccount(BaseModel):
489
520
  https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#delete-draft-comments-input
490
521
  :return:
491
522
  """
492
- return self.gerrit.post(self.endpoint + "/drafts:delete",
493
- json=input_, headers=self.gerrit.default_headers)
523
+ return self.gerrit.post(
524
+ self.endpoint + "/drafts:delete",
525
+ json=input_,
526
+ headers=self.gerrit.default_headers,
527
+ )
494
528
 
495
529
  def index(self):
496
530
  """
@@ -566,5 +600,8 @@ class GerritAccount(BaseModel):
566
600
  https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#stars-input
567
601
  :return:
568
602
  """
569
- return self.gerrit.post(self.endpoint + f"/stars.changes/{id_}",
570
- json=input_, headers=self.gerrit.default_headers)
603
+ return self.gerrit.post(
604
+ self.endpoint + f"/stars.changes/{id_}",
605
+ json=input_,
606
+ headers=self.gerrit.default_headers,
607
+ )
@@ -12,8 +12,8 @@ class GerritAccounts(object):
12
12
  def search(
13
13
  self,
14
14
  query,
15
- limit=None,
16
- skip=None,
15
+ limit=25,
16
+ skip=0,
17
17
  detailed=False,
18
18
  suggested=False,
19
19
  all_emails=False,
@@ -52,16 +52,16 @@ class GerritAccounts(object):
52
52
 
53
53
  return self.gerrit.get(endpoint, params=params)
54
54
 
55
- def get(self, username, detailed=False):
55
+ def get(self, account, detailed=False):
56
56
  """
57
57
  Returns an account
58
58
 
59
- :param username: username or _account_id
59
+ :param account: username or email or _account_id or 'self'
60
60
  :param detailed: boolean type, If True then fetch info in more details, such as:
61
61
  registered_on
62
62
  :return:
63
63
  """
64
- endpoint = self.endpoint + f"/{username}/"
64
+ endpoint = self.endpoint + f"/{account}/"
65
65
  if detailed:
66
66
  endpoint += "detail"
67
67
  result = self.gerrit.get(endpoint)
@@ -90,5 +90,8 @@ class GerritAccounts(object):
90
90
  :return:
91
91
  """
92
92
  result = self.gerrit.put(
93
- self.endpoint + f"/{username}", json=input_, headers=self.gerrit.default_headers)
93
+ self.endpoint + f"/{username}",
94
+ json=input_,
95
+ headers=self.gerrit.default_headers,
96
+ )
94
97
  return GerritAccount(json=result, gerrit=self.gerrit)
@@ -8,7 +8,7 @@ class GerritAccountEmail(BaseModel):
8
8
  def __init__(self, **kwargs):
9
9
  super().__init__(**kwargs)
10
10
  self.entity_name = "email"
11
- self.endpoint = f"/accounts/{self.username}/emails/{self.email}"
11
+ self.endpoint = f"/accounts/{self.account_id}/emails/{self.email}"
12
12
 
13
13
  def delete(self):
14
14
  """
@@ -28,10 +28,10 @@ class GerritAccountEmail(BaseModel):
28
28
 
29
29
 
30
30
  class GerritAccountEmails(object):
31
- def __init__(self, username, gerrit):
32
- self.username = username
31
+ def __init__(self, account_id, gerrit):
32
+ self.account_id = account_id
33
33
  self.gerrit = gerrit
34
- self.endpoint = f"/accounts/{self.username}/emails"
34
+ self.endpoint = f"/accounts/{self.account_id}/emails"
35
35
 
36
36
  def list(self):
37
37
  """
@@ -40,7 +40,9 @@ class GerritAccountEmails(object):
40
40
  :return:
41
41
  """
42
42
  result = self.gerrit.get(self.endpoint)
43
- return GerritAccountEmail.parse_list(result, username=self.username, gerrit=self.gerrit)
43
+ return GerritAccountEmail.parse_list(
44
+ result, account_id=self.account_id, gerrit=self.gerrit
45
+ )
44
46
 
45
47
  def create(self, email):
46
48
  """
@@ -57,7 +59,9 @@ class GerritAccountEmails(object):
57
59
  :return:
58
60
  """
59
61
  result = self.gerrit.get(self.endpoint + f"/{email}")
60
- return GerritAccountEmail(json=result, username=self.username, gerrit=self.gerrit)
62
+ return GerritAccountEmail(
63
+ json=result, account_id=self.account_id, gerrit=self.gerrit
64
+ )
61
65
 
62
66
  def set_preferred(self, email):
63
67
  """
@@ -7,7 +7,7 @@ from gerrit.utils.models import BaseModel
7
7
  class GerritAccountGPGKey(BaseModel):
8
8
  def __init__(self, **kwargs):
9
9
  super().__init__(**kwargs)
10
- self.endpoint = f"/accounts/{self.username}/gpgkeys"
10
+ self.endpoint = f"/accounts/{self.account_id}/gpgkeys"
11
11
 
12
12
  def delete(self):
13
13
  """
@@ -19,10 +19,10 @@ class GerritAccountGPGKey(BaseModel):
19
19
 
20
20
 
21
21
  class GerritAccountGPGKeys(object):
22
- def __init__(self, username, gerrit):
23
- self.username = username
22
+ def __init__(self, account_id, gerrit):
23
+ self.account_id = account_id
24
24
  self.gerrit = gerrit
25
- self.endpoint = f"/accounts/{self.username}/gpgkeys"
25
+ self.endpoint = f"/accounts/{self.account_id}/gpgkeys"
26
26
 
27
27
  def list(self):
28
28
  """
@@ -38,7 +38,7 @@ class GerritAccountGPGKeys(object):
38
38
  keys.append(gpg_key)
39
39
 
40
40
  return GerritAccountGPGKey.parse_list(
41
- keys, username=self.username, gerrit=self.gerrit
41
+ keys, account_id=self.account_id, gerrit=self.gerrit
42
42
  )
43
43
 
44
44
  def get(self, id_):
@@ -49,7 +49,9 @@ class GerritAccountGPGKeys(object):
49
49
  :return:
50
50
  """
51
51
  result = self.gerrit.get(self.endpoint + f"/{id_}")
52
- return GerritAccountGPGKey(json=result, username=self.username, gerrit=self.gerrit)
52
+ return GerritAccountGPGKey(
53
+ json=result, account_id=self.account_id, gerrit=self.gerrit
54
+ )
53
55
 
54
56
  def modify(self, input_):
55
57
  """
@@ -100,7 +102,9 @@ class GerritAccountGPGKeys(object):
100
102
  https://gerrit-review.googlesource.com/Documentation/rest-api-accounts.html#gpg-keys-input
101
103
  :return:
102
104
  """
103
- return self.gerrit.post(self.endpoint, json=input_, headers=self.gerrit.default_headers)
105
+ return self.gerrit.post(
106
+ self.endpoint, json=input_, headers=self.gerrit.default_headers
107
+ )
104
108
 
105
109
  def delete(self, id_):
106
110
  """
@@ -8,7 +8,7 @@ class GerritAccountSSHKey(BaseModel):
8
8
  def __init__(self, **kwargs):
9
9
  super().__init__(**kwargs)
10
10
  self.entity_name = "seq"
11
- self.endpoint = f"/accounts/{self.username}/sshkeys"
11
+ self.endpoint = f"/accounts/{self.account_id}/sshkeys"
12
12
 
13
13
  def delete(self):
14
14
  """
@@ -20,10 +20,10 @@ class GerritAccountSSHKey(BaseModel):
20
20
 
21
21
 
22
22
  class GerritAccountSSHKeys(object):
23
- def __init__(self, username, gerrit):
24
- self.username = username
23
+ def __init__(self, account_id, gerrit):
24
+ self.account_id = account_id
25
25
  self.gerrit = gerrit
26
- self.endpoint = f"/accounts/{self.username}/sshkeys"
26
+ self.endpoint = f"/accounts/{self.account_id}/sshkeys"
27
27
 
28
28
  def list(self):
29
29
  """
@@ -32,7 +32,9 @@ class GerritAccountSSHKeys(object):
32
32
  :return:
33
33
  """
34
34
  result = self.gerrit.get(self.endpoint)
35
- return GerritAccountSSHKey.parse_list(result, username=self.username, gerrit=self.gerrit)
35
+ return GerritAccountSSHKey.parse_list(
36
+ result, account_id=self.account_id, gerrit=self.gerrit
37
+ )
36
38
 
37
39
  def get(self, seq):
38
40
  """
@@ -42,7 +44,9 @@ class GerritAccountSSHKeys(object):
42
44
  :return:
43
45
  """
44
46
  result = self.gerrit.get(self.endpoint + f"/{str(seq)}")
45
- return GerritAccountSSHKey(json=result, username=self.username, gerrit=self.gerrit)
47
+ return GerritAccountSSHKey(
48
+ json=result, account_id=self.account_id, gerrit=self.gerrit
49
+ )
46
50
 
47
51
  def add(self, ssh_key):
48
52
  """
@@ -52,9 +56,12 @@ class GerritAccountSSHKeys(object):
52
56
  :param ssh_key: SSH key raw content
53
57
  :return:
54
58
  """
55
- result = self.gerrit.post(self.endpoint,
56
- data=ssh_key, headers={"Content-Type": "plain/text"})
57
- return GerritAccountSSHKey(json=result, username=self.username, gerrit=self.gerrit)
59
+ result = self.gerrit.post(
60
+ self.endpoint, data=ssh_key, headers={"Content-Type": "plain/text"}
61
+ )
62
+ return GerritAccountSSHKey(
63
+ json=result, account_id=self.account_id, gerrit=self.gerrit
64
+ )
58
65
 
59
66
  def delete(self, seq):
60
67
  """