Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2411bff

Browse files
nicoklausnejch
authored andcommitted
feat(projects): add pull mirror class
1 parent5c11203 commit2411bff

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+
classProjectPullMirror(SaveMixin,RESTObject):
1247+
_id_attr=None
1248+
1249+
1250+
classProjectPullMirrorManager(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+
defget(self,**kwargs:Any)->ProjectPullMirror:
1257+
returncast(ProjectPullMirror,super().get(**kwargs))
1258+
1259+
@exc.on_http_error(exc.GitlabCreateError)
1260+
defcreate(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+
ifTYPE_CHECKING:
1277+
assertdataisnotNone
1278+
self._create_attrs.validate_attrs(data=data)
1279+
1280+
ifTYPE_CHECKING:
1281+
assertself.pathisnotNone
1282+
server_data=self.gitlab.http_put(self.path,post_data=data,**kwargs)
1283+
1284+
ifTYPE_CHECKING:
1285+
assertnotisinstance(server_data,requests.Response)
1286+
returnself._obj_cls(self,server_data)
1287+
1288+
@cli.register_custom_action(cls_names="ProjectPullMirrorManager")
1289+
@exc.on_http_error(exc.GitlabCreateError)
1290+
defstart(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+
ifTYPE_CHECKING:
1301+
assertself.pathisnotNone
1302+
self.gitlab.http_post(self.path,**kwargs)
1303+
1304+
12431305
classProjectStorage(RefreshMixin,RESTObject):
12441306
pass
12451307

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp