| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5c11203 commit 2411bff
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -128,6 +128,8 @@ | |||
| 128 | 128 | "ProjectForkManager", | |
| 129 | 129 | "ProjectRemoteMirror", | |
| 130 | 130 | "ProjectRemoteMirrorManager", | |
| 131 | + "ProjectPullMirror", | ||
| 132 | + "ProjectPullMirrorManager", | ||
| 131 | 133 | "ProjectStorage", | |
| 132 | 134 | "ProjectStorageManager", | |
| 133 | 135 | "SharedProject", | |
@@ -249,6 +251,7 @@ class Project( | |||
| 249 | 251 | releases: ProjectReleaseManager | |
| 250 | 252 | resource_groups: ProjectResourceGroupManager | |
| 251 | 253 | remote_mirrors: "ProjectRemoteMirrorManager" | |
| 254 | + pull_mirror: "ProjectPullMirrorManager" | ||
| 252 | 255 | repositories: ProjectRegistryRepositoryManager | |
| 253 | 256 | runners: ProjectRunnerManager | |
| 254 | 257 | secure_files: ProjectSecureFileManager | |
@@ -1240,6 +1243,65 @@ class ProjectRemoteMirrorManager( | |||
| 1240 | 1243 | _update_attrs = RequiredOptional(optional=("enabled", "only_protected_branches")) | |
| 1241 | 1244 | ||
| 1242 | 1245 | ||
| 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 | + | ||
| 1243 | 1305 | class ProjectStorage(RefreshMixin, RESTObject): | |
| 1244 | 1306 | pass | |
| 1245 | 1307 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments