summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/gl_objects/environments.rst4
-rw-r--r--gitlab/exceptions.py4
-rw-r--r--gitlab/v4/objects.py15
-rw-r--r--tools/python_test_v4.py1
4 files changed, 23 insertions, 1 deletions
diff --git a/docs/gl_objects/environments.rst b/docs/gl_objects/environments.rst
index 1867d24..a05a6fc 100644
--- a/docs/gl_objects/environments.rst
+++ b/docs/gl_objects/environments.rst
@@ -34,3 +34,7 @@ Delete an environment for a project::
environment = project.environments.delete(environment_id)
# or
environment.delete()
+
+Stop an environments::
+
+ environment.stop()
diff --git a/gitlab/exceptions.py b/gitlab/exceptions.py
index 00d99c6..9e3fa4a 100644
--- a/gitlab/exceptions.py
+++ b/gitlab/exceptions.py
@@ -201,6 +201,10 @@ class GitlabSearchError(GitlabOperationError):
pass
+class GitlabStopError(GitlabOperationError):
+ pass
+
+
def on_http_error(error):
"""Manage GitlabHttpError exceptions.
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
index da2f6ed..6c0c84f 100644
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -1278,7 +1278,20 @@ class ProjectCommitManager(RetrieveMixin, CreateMixin, RESTManager):
class ProjectEnvironment(SaveMixin, ObjectDeleteMixin, RESTObject):
- pass
+ @cli.register_custom_action('ProjectEnvironment')
+ @exc.on_http_error(exc.GitlabStopError)
+ def stop(self, **kwargs):
+ """Stop the environment.
+
+ Args:
+ **kwargs: Extra options to send to the server (e.g. sudo)
+
+ Raises:
+ GitlabAuthenticationError: If authentication is not correct
+ GitlabStopError: If the operation failed
+ """
+ path = '%s/%s/stop' % (self.manager.path, self.get_id())
+ self.manager.gitlab.http_post(path, **kwargs)
class ProjectEnvironmentManager(ListMixin, CreateMixin, UpdateMixin,
diff --git a/tools/python_test_v4.py b/tools/python_test_v4.py
index 0551093..37f657a 100644
--- a/tools/python_test_v4.py
+++ b/tools/python_test_v4.py
@@ -432,6 +432,7 @@ env.external_url = 'http://new.env/whatever'
env.save()
env = admin_project.environments.list()[0]
assert(env.external_url == 'http://new.env/whatever')
+env.stop()
env.delete()
assert(len(admin_project.environments.list()) == 0)