summaryrefslogtreecommitdiff
path: root/gitlab
diff options
context:
space:
mode:
authorNejc Habjan <hab.nejc@gmail.com>2021-12-11 13:18:49 +0100
committerJohn Villalovos <john@sodarock.com>2021-12-11 10:25:08 -0800
commite7559bfa2ee265d7d664d7a18770b0a3e80cf999 (patch)
tree70b0193d60a06d2d1cd364c2425c87c4029dc72d /gitlab
parentac5defa0c09822cf2208e66218a37d3ce00ff35b (diff)
downloadgitlab-e7559bfa2ee265d7d664d7a18770b0a3e80cf999.tar.gz
feat(api): add support for Topics API
Diffstat (limited to 'gitlab')
-rw-r--r--gitlab/client.py2
-rw-r--r--gitlab/v4/objects/__init__.py1
-rw-r--r--gitlab/v4/objects/topics.py27
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))