Skip to content

Commit f91abf3

Browse files
committed
feat(api): Added project template classes to templates.py
1 parent 288f39c commit f91abf3

File tree

1 file changed

+104
-0
lines changed

1 file changed

+104
-0
lines changed

gitlab/v4/objects/templates.py

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212
"GitlabciymlManager",
1313
"License",
1414
"LicenseManager",
15+
"ProjectDockerfileTemplate",
16+
"ProjectDockerfileTemplateManager",
17+
"ProjectGitignoreTemplate",
18+
"ProjectGitignoreTemplateManager",
19+
"ProjectGitlabciymlTemplate",
20+
"ProjectGitlabciymlTemplateManager",
21+
"ProjectIssueTemplate",
22+
"ProjectIssueTemplateManager",
23+
"ProjectLicenseTemplate",
24+
"ProjectLicenseTemplateManager",
25+
"ProjectMergeRequestTemplate",
26+
"ProjectMergeRequestTemplateManager",
1527
]
1628

1729

@@ -65,3 +77,95 @@ class LicenseManager(RetrieveMixin, RESTManager):
6577

6678
def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> License:
6779
return cast(License, super().get(id=id, lazy=lazy, **kwargs))
80+
81+
82+
class ProjectDockerfileTemplate(RESTObject):
83+
_id_attr = "name"
84+
85+
86+
class ProjectDockerfileTemplateManager(RetrieveMixin, RESTManager):
87+
_path = "/projects/{project_id}/templates/dockerfiles"
88+
_obj_cls = ProjectDockerfileTemplate
89+
_from_parent_attrs = {"project_id": "id"}
90+
91+
def get(
92+
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
93+
) -> ProjectDockerfileTemplate:
94+
return cast(ProjectDockerfileTemplate, super().get(id=id, lazy=lazy, **kwargs))
95+
96+
97+
class ProjectGitignoreTemplate(RESTObject):
98+
_id_attr = "name"
99+
100+
101+
class ProjectGitignoreTemplateManager(RetrieveMixin, RESTManager):
102+
_path = "/projects/{project_id}/templates/gitignores"
103+
_obj_cls = ProjectGitignoreTemplate
104+
_from_parent_attrs = {"project_id": "id"}
105+
106+
def get(
107+
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
108+
) -> ProjectGitignoreTemplate:
109+
return cast(ProjectGitignoreTemplate, super().get(id=id, lazy=lazy, **kwargs))
110+
111+
112+
class ProjectGitlabciymlTemplate(RESTObject):
113+
_id_attr = "name"
114+
115+
116+
class ProjectGitlabciymlTemplateManager(RetrieveMixin, RESTManager):
117+
_path = "/projects/{project_id}/templates/gitlab_ci_ymls"
118+
_obj_cls = ProjectGitlabciymlTemplate
119+
_from_parent_attrs = {"project_id": "id"}
120+
121+
def get(
122+
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
123+
) -> ProjectGitlabciymlTemplate:
124+
return cast(ProjectGitlabciymlTemplate, super().get(id=id, lazy=lazy, **kwargs))
125+
126+
127+
class ProjectLicenseTemplate(RESTObject):
128+
_id_attr = "key"
129+
130+
131+
class ProjectLicenseTemplateManager(RetrieveMixin, RESTManager):
132+
_path = "/projects/{project_id}/templates/licenses"
133+
_obj_cls = ProjectLicenseTemplate
134+
_from_parent_attrs = {"project_id": "id"}
135+
136+
def get(
137+
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
138+
) -> ProjectLicenseTemplate:
139+
return cast(ProjectLicenseTemplate, super().get(id=id, lazy=lazy, **kwargs))
140+
141+
142+
class ProjectIssueTemplate(RESTObject):
143+
_id_attr = "name"
144+
145+
146+
class ProjectIssueTemplateManager(RetrieveMixin, RESTManager):
147+
_path = "/projects/{project_id}/templates/issues"
148+
_obj_cls = ProjectIssueTemplate
149+
_from_parent_attrs = {"project_id": "id"}
150+
151+
def get(
152+
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
153+
) -> ProjectIssueTemplate:
154+
return cast(ProjectIssueTemplate, super().get(id=id, lazy=lazy, **kwargs))
155+
156+
157+
class ProjectMergeRequestTemplate(RESTObject):
158+
_id_attr = "name"
159+
160+
161+
class ProjectMergeRequestTemplateManager(RetrieveMixin, RESTManager):
162+
_path = "/projects/{project_id}/templates/merge_requests"
163+
_obj_cls = ProjectMergeRequestTemplate
164+
_from_parent_attrs = {"project_id": "id"}
165+
166+
def get(
167+
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
168+
) -> ProjectMergeRequestTemplate:
169+
return cast(
170+
ProjectMergeRequestTemplate, super().get(id=id, lazy=lazy, **kwargs)
171+
)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy