diff options
| author | Nejc Habjan <hab.nejc@gmail.com> | 2021-12-11 13:18:49 +0100 |
|---|---|---|
| committer | John Villalovos <john@sodarock.com> | 2021-12-11 10:25:08 -0800 |
| commit | e7559bfa2ee265d7d664d7a18770b0a3e80cf999 (patch) | |
| tree | 70b0193d60a06d2d1cd364c2425c87c4029dc72d /gitlab | |
| parent | ac5defa0c09822cf2208e66218a37d3ce00ff35b (diff) | |
| download | gitlab-e7559bfa2ee265d7d664d7a18770b0a3e80cf999.tar.gz | |
feat(api): add support for Topics API
Diffstat (limited to 'gitlab')
| -rw-r--r-- | gitlab/client.py | 2 | ||||
| -rw-r--r-- | gitlab/v4/objects/__init__.py | 1 | ||||
| -rw-r--r-- | gitlab/v4/objects/topics.py | 27 |
3 files changed, 30 insertions, 0 deletions
diff --git a/gitlab/client.py b/gitlab/client.py index 0dd4a6d..d3fdaab 100644 --- a/gitlab/client.py +++ b/gitlab/client.py @@ -180,6 +180,8 @@ class Gitlab(object): """See :class:`~gitlab.v4.objects.VariableManager`""" self.personal_access_tokens = objects.PersonalAccessTokenManager(self) """See :class:`~gitlab.v4.objects.PersonalAccessTokenManager`""" + self.topics = objects.TopicManager(self) + """See :class:`~gitlab.v4.objects.TopicManager`""" def __enter__(self) -> "Gitlab": return self diff --git a/gitlab/v4/objects/__init__.py b/gitlab/v4/objects/__init__.py index b1d6484..0ab3bd4 100644 --- a/gitlab/v4/objects/__init__.py +++ b/gitlab/v4/objects/__init__.py @@ -70,6 +70,7 @@ from .statistics import * from .tags import * from .templates import * from .todos import * +from .topics import * from .triggers import * from .users import * from .variables import * diff --git a/gitlab/v4/objects/topics.py b/gitlab/v4/objects/topics.py new file mode 100644 index 0000000..76208ed --- /dev/null +++ b/gitlab/v4/objects/topics.py @@ -0,0 +1,27 @@ +from typing import Any, cast, Union + +from gitlab import types +from gitlab.base import RequiredOptional, RESTManager, RESTObject +from gitlab.mixins import CRUDMixin, ObjectDeleteMixin, SaveMixin + +__all__ = [ + "Topic", + "TopicManager", +] + + +class Topic(SaveMixin, ObjectDeleteMixin, RESTObject): + pass + + +class TopicManager(CRUDMixin, RESTManager): + _path = "/topics" + _obj_cls = Topic + _create_attrs = RequiredOptional( + required=("name",), optional=("avatar", "description") + ) + _update_attrs = RequiredOptional(optional=("avatar", "description", "name")) + _types = {"avatar": types.ImageAttribute} + + def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Topic: + return cast(Topic, super().get(id=id, lazy=lazy, **kwargs)) |
