Skip to content

Commit 50921b3

Browse files
committed
Remove redundant url_params info in specification
Just parse the params out of the url rather than explicitly listing them.
1 parent 2124442 commit 50921b3

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

gitlab3/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def _get_http_request_fn(api, method):
215215
def _add_extra_fn(api, action_def, parent=None):
216216
required_params = action_def.required_params
217217
# url_params are required params, but get passed as part of url
218-
url_params = action_def.url_params
218+
url_params = re.findall(':(\w+)', action_def.url)
219219
http_method = action_def.method
220220
url = api._q_url # XXX: do any extra fns need unqualified url?
221221
url += action_def.url

gitlab3/_api_definition.py

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ def plural_name(cls):
4949
class ExtraActionDefinition(object):
5050
"""Definition of a "non-standard" function"""
5151
url = ''
52-
url_params = []
5352
required_params = []
5453
optional_params = []
5554

@@ -150,30 +149,21 @@ class ForkFromAction(ExtraActionDefinition):
150149
"""gl.Project.fork_from(forked_from_id)"""
151150
url = '/fork/:forked_from_id'
152151
method = _HTTP_POST
153-
url_params = [
154-
'forked_from_id',
155-
]
156152
class DeleteForkAction(ExtraActionDefinition):
157153
"""gl.Project.delete_fork()"""
158154
url = '/fork'
159155
method = _HTTP_DELETE
160156
class GetBlobAction(ExtraActionDefinition):
161157
"""gl.Project.get_blob()"""
162-
url = '/repository/commits/:sha/blob'
158+
url = '/repository/commits/:sha_or_ref_name/blob'
163159
method = _HTTP_GET
164-
url_params = [
165-
'sha_or_ref_name',
166-
]
167160
required_params = [
168161
'filepath',
169162
]
170163
class ProtectBranchAction(ExtraActionDefinition):
171164
"""gl.Project.protect_branch()"""
172165
url = '/repository/branches/:branch/protect'
173166
method = _HTTP_PUT
174-
url_params = [
175-
'branch', # GitLab API is branch name
176-
]
177167
@staticmethod
178168
def wrapper(extra_action_fn, parent):
179169
"""Accept a Branch object instead of a branch name"""
@@ -189,9 +179,6 @@ class UnprotectBranchAction(ExtraActionDefinition):
189179
"""gl.Project.unprotect_branch()"""
190180
url = '/repository/branches/:branch/unprotect'
191181
method = _HTTP_PUT
192-
url_params = [
193-
'branch', # GitLab API is branch name
194-
]
195182
@staticmethod
196183
def wrapper(extra_action_fn, parent):
197184
"""Accept a Branch object instead of a branch name"""
@@ -447,9 +434,6 @@ class AddProjectForUserAction(ExtraActionDefinition):
447434
"""gl.add_project_for_user(user_id, name)"""
448435
url = '/projects/user/:user_id'
449436
method = _HTTP_POST
450-
url_params = [
451-
'user_id',
452-
]
453437
required_params = [
454438
'name',
455439
]

0 commit comments

Comments
 (0)