summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2017-11-12 07:38:28 +0100
committerGauvain Pocentek <gauvain@pocentek.net>2017-11-12 07:38:28 +0100
commit9ede6529884e850532758ae218465c1b7584c2d4 (patch)
tree9ad4c053ac296dd478420acf6636db76ff180106
parent4ee139ad5c58006da1f9af93fdd4e70592e6daa0 (diff)
downloadgitlab-9ede6529884e850532758ae218465c1b7584c2d4.tar.gz
Add support for project housekeeping
Closes #368
-rw-r--r--docs/gl_objects/projects.py4
-rw-r--r--docs/gl_objects/projects.rst6
-rw-r--r--gitlab/exceptions.py4
-rw-r--r--gitlab/v4/objects.py16
-rw-r--r--tools/python_test_v4.py3
5 files changed, 33 insertions, 0 deletions
diff --git a/docs/gl_objects/projects.py b/docs/gl_objects/projects.py
index 878e45d..515397f 100644
--- a/docs/gl_objects/projects.py
+++ b/docs/gl_objects/projects.py
@@ -180,6 +180,10 @@ tgz = project.repository_archive(sha='4567abc')
contributors = project.repository_contributors()
# end repository contributors
+# housekeeping
+project.housekeeping()
+# end housekeeping
+
# files get
f = project.files.get(file_path='README.rst', ref='master')
diff --git a/docs/gl_objects/projects.rst b/docs/gl_objects/projects.rst
index eb15a3b..aaf0699 100644
--- a/docs/gl_objects/projects.rst
+++ b/docs/gl_objects/projects.rst
@@ -114,6 +114,12 @@ Archive/unarchive a project:
Previous versions used ``archive_`` and ``unarchive_`` due to a naming issue,
they have been deprecated but not yet removed.
+Start the housekeeping job:
+
+.. literalinclude:: projects.py
+ :start-after: # housekeeping
+ :end-before: # end housekeeping
+
List the repository tree:
.. literalinclude:: projects.py
diff --git a/gitlab/exceptions.py b/gitlab/exceptions.py
index d95bb08..9a423dd 100644
--- a/gitlab/exceptions.py
+++ b/gitlab/exceptions.py
@@ -189,6 +189,10 @@ class GitlabCherryPickError(GitlabOperationError):
pass
+class GitlabHousekeepingError(GitlabOperationError):
+ pass
+
+
def raise_error_from_response(response, error, expected_code=200):
"""Tries to parse gitlab error message from response and raises error.
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
index 77a6a72..85aba12 100644
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -2328,6 +2328,22 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject):
post_data = {'ref': ref, 'token': token, 'variables': variables}
self.manager.gitlab.http_post(path, post_data=post_data, **kwargs)
+ @cli.register_custom_action('Project')
+ @exc.on_http_error(exc.GitlabHousekeepingError)
+ def housekeeping(self, **kwargs):
+ """Start the housekeeping task.
+
+ Args:
+ **kwargs: Extra options to send to the server (e.g. sudo)
+
+ Raises:
+ GitlabAuthenticationError: If authentication is not correct
+ GitlabHousekeepingError: If the server failed to perform the
+ request
+ """
+ path = '/projects/%s/housekeeping' % self.get_id()
+ self.manager.gitlab.http_post(path, **kwargs)
+
# see #56 - add file attachment features
@cli.register_custom_action('Project', ('filename', 'filepath'))
@exc.on_http_error(exc.GitlabUploadError)
diff --git a/tools/python_test_v4.py b/tools/python_test_v4.py
index f126719..f9ef83a 100644
--- a/tools/python_test_v4.py
+++ b/tools/python_test_v4.py
@@ -331,6 +331,9 @@ assert(len(commit.statuses.list()) == 1)
commit.comments.create({'note': 'This is a commit comment'})
assert(len(commit.comments.list()) == 1)
+# housekeeping
+admin_project.housekeeping()
+
# repository
tree = admin_project.repository_tree()
assert(len(tree) != 0)