summaryrefslogtreecommitdiff
path: root/gitlab/v4/objects/templates.py
blob: bbe2ae6c1acf42a53cbed85714ce971661c0580e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from typing import Any, cast, Union

from gitlab.base import RESTManager, RESTObject
from gitlab.mixins import RetrieveMixin

__all__ = [
    "Dockerfile",
    "DockerfileManager",
    "Gitignore",
    "GitignoreManager",
    "Gitlabciyml",
    "GitlabciymlManager",
    "License",
    "LicenseManager",
]


class Dockerfile(RESTObject):
    _id_attr = "name"


class DockerfileManager(RetrieveMixin, RESTManager):
    _path = "/templates/dockerfiles"
    _obj_cls = Dockerfile

    def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Dockerfile:
        return cast(Dockerfile, super().get(id=id, lazy=lazy, **kwargs))


class Gitignore(RESTObject):
    _id_attr = "name"


class GitignoreManager(RetrieveMixin, RESTManager):
    _path = "/templates/gitignores"
    _obj_cls = Gitignore

    def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Gitignore:
        return cast(Gitignore, super().get(id=id, lazy=lazy, **kwargs))


class Gitlabciyml(RESTObject):
    _id_attr = "name"


class GitlabciymlManager(RetrieveMixin, RESTManager):
    _path = "/templates/gitlab_ci_ymls"
    _obj_cls = Gitlabciyml

    def get(
        self, id: Union[str, int], lazy: bool = False, **kwargs: Any
    ) -> Gitlabciyml:
        return cast(Gitlabciyml, super().get(id=id, lazy=lazy, **kwargs))


class License(RESTObject):
    _id_attr = "key"


class LicenseManager(RetrieveMixin, RESTManager):
    _path = "/templates/licenses"
    _obj_cls = License
    _list_filters = ("popular",)
    _optional_get_attrs = ("project", "fullname")

    def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> License:
        return cast(License, super().get(id=id, lazy=lazy, **kwargs))