diff options
author | Gauvain Pocentek <gauvain@pocentek.net> | 2018-06-09 17:22:39 +0200 |
---|---|---|
committer | Gauvain Pocentek <gauvain@pocentek.net> | 2018-06-09 17:22:47 +0200 |
commit | 39c8ad5a9405469370e429548e08aa475797b92b (patch) | |
tree | 5f27f5e22bb290aba927a84df81a9453b0aa9bc5 /gitlab/v4/objects.py | |
parent | 5a855fdb7f9eadc00e8b917d43a601fdc45d514a (diff) | |
download | gitlab-39c8ad5a9405469370e429548e08aa475797b92b.tar.gz |
Add geo nodes API support
Fixes #524
Diffstat (limited to 'gitlab/v4/objects.py')
-rw-r--r-- | gitlab/v4/objects.py | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py index d6ae6c5..8feb09b 100644 --- a/gitlab/v4/objects.py +++ b/gitlab/v4/objects.py @@ -3444,3 +3444,80 @@ class TodoManager(ListMixin, DeleteMixin, RESTManager): return int(result) except ValueError: return 0 + + +class GeoNode(SaveMixin, ObjectDeleteMixin, RESTObject): + @cli.register_custom_action('GeoNode') + @exc.on_http_error(exc.GitlabRepairError) + def repair(self, **kwargs): + """Repair the OAuth authentication of the geo node. + + Args: + **kwargs: Extra options to send to the server (e.g. sudo) + + Raises: + GitlabAuthenticationError: If authentication is not correct + GitlabRepairError: If the server failed to perform the request + """ + path = '/geo_nodes/%s/repair' % self.get_id() + server_data = self.manager.gitlab.http_post(path, **kwargs) + self._update_attrs(server_data) + + @cli.register_custom_action('GeoNode') + @exc.on_http_error(exc.GitlabGetError) + def status(self, **kwargs): + """Get the status of the geo node. + + Args: + **kwargs: Extra options to send to the server (e.g. sudo) + + Raises: + GitlabAuthenticationError: If authentication is not correct + GitlabGetError: If the server failed to perform the request + + Returns: + dict: The status of the geo node + """ + path = '/geo_nodes/%s/status' % self.get_id() + return self.manager.gitlab.http_get(path, **kwargs) + + +class GeoNodeManager(RetrieveMixin, UpdateMixin, DeleteMixin, RESTManager): + _path = '/geo_nodes' + _obj_cls = GeoNode + _update_attrs = (tuple(), ('enabled', 'url', 'files_max_capacity', + 'repos_max_capacity')) + + @cli.register_custom_action('GeoNodeManager') + @exc.on_http_error(exc.GitlabGetError) + def status(self, **kwargs): + """Get the status of all the geo nodes. + + Args: + **kwargs: Extra options to send to the server (e.g. sudo) + + Raises: + GitlabAuthenticationError: If authentication is not correct + GitlabGetError: If the server failed to perform the request + + Returns: + list: The status of all the geo nodes + """ + return self.gitlab.http_list('/geo_nodes/status', **kwargs) + + @cli.register_custom_action('GeoNodeManager') + @exc.on_http_error(exc.GitlabGetError) + def current_failures(self, **kwargs): + """Get the list of failures on the current geo node. + + Args: + **kwargs: Extra options to send to the server (e.g. sudo) + + Raises: + GitlabAuthenticationError: If authentication is not correct + GitlabGetError: If the server failed to perform the request + + Returns: + list: The list of failures + """ + return self.gitlab.http_list('/geo_nodes/current/failures', **kwargs) |