Skip to content

Commit 2411bff

Browse files
nicoklausnejch
authored andcommitted
feat(projects): add pull mirror class
1 parent 5c11203 commit 2411bff

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

gitlab/v4/objects/projects.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@
128128
"ProjectForkManager",
129129
"ProjectRemoteMirror",
130130
"ProjectRemoteMirrorManager",
131+
"ProjectPullMirror",
132+
"ProjectPullMirrorManager",
131133
"ProjectStorage",
132134
"ProjectStorageManager",
133135
"SharedProject",
@@ -249,6 +251,7 @@ class Project(
249251
releases: ProjectReleaseManager
250252
resource_groups: ProjectResourceGroupManager
251253
remote_mirrors: "ProjectRemoteMirrorManager"
254+
pull_mirror: "ProjectPullMirrorManager"
252255
repositories: ProjectRegistryRepositoryManager
253256
runners: ProjectRunnerManager
254257
secure_files: ProjectSecureFileManager
@@ -1240,6 +1243,65 @@ class ProjectRemoteMirrorManager(
12401243
_update_attrs = RequiredOptional(optional=("enabled", "only_protected_branches"))
12411244

12421245

1246+
class ProjectPullMirror(SaveMixin, RESTObject):
1247+
_id_attr = None
1248+
1249+
1250+
class ProjectPullMirrorManager(GetWithoutIdMixin, UpdateMixin, RESTManager):
1251+
_path = "/projects/{project_id}/mirror/pull"
1252+
_obj_cls = ProjectPullMirror
1253+
_from_parent_attrs = {"project_id": "id"}
1254+
_update_attrs = RequiredOptional(optional=("url",))
1255+
1256+
def get(self, **kwargs: Any) -> ProjectPullMirror:
1257+
return cast(ProjectPullMirror, super().get(**kwargs))
1258+
1259+
@exc.on_http_error(exc.GitlabCreateError)
1260+
def create(self, data: Dict[str, Any], **kwargs: Any) -> ProjectPullMirror:
1261+
"""Create a new object.
1262+
1263+
Args:
1264+
data: parameters to send to the server to create the
1265+
resource
1266+
**kwargs: Extra options to send to the server (e.g. sudo)
1267+
1268+
Returns:
1269+
A new instance of the managed object class built with
1270+
the data sent by the server
1271+
1272+
Raises:
1273+
GitlabAuthenticationError: If authentication is not correct
1274+
GitlabCreateError: If the server cannot perform the request
1275+
"""
1276+
if TYPE_CHECKING:
1277+
assert data is not None
1278+
self._create_attrs.validate_attrs(data=data)
1279+
1280+
if TYPE_CHECKING:
1281+
assert self.path is not None
1282+
server_data = self.gitlab.http_put(self.path, post_data=data, **kwargs)
1283+
1284+
if TYPE_CHECKING:
1285+
assert not isinstance(server_data, requests.Response)
1286+
return self._obj_cls(self, server_data)
1287+
1288+
@cli.register_custom_action(cls_names="ProjectPullMirrorManager")
1289+
@exc.on_http_error(exc.GitlabCreateError)
1290+
def start(self, **kwargs: Any) -> None:
1291+
"""Start the pull mirroring process for the project.
1292+
1293+
Args:
1294+
**kwargs: Extra options to send to the server (e.g. sudo)
1295+
1296+
Raises:
1297+
GitlabAuthenticationError: If authentication is not correct
1298+
GitlabCreateError: If the server failed to perform the request
1299+
"""
1300+
if TYPE_CHECKING:
1301+
assert self.path is not None
1302+
self.gitlab.http_post(self.path, **kwargs)
1303+
1304+
12431305
class ProjectStorage(RefreshMixin, RESTObject):
12441306
pass
12451307

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