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

Commit060cfe1

Browse files
JohnVillalovosnejch
authored andcommitted
feat(api): add support for getting a project's pull mirror details
Add the ability to get a project's pull mirror details. This was addedin GitLab 15.5 and is a PREMIUM feature.https://docs.gitlab.com/ee/api/projects.html#get-a-projects-pull-mirror-details
1 parent12aea32 commit060cfe1

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

‎docs/gl_objects/projects.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ Start the pull mirroring process (EE edition)::
250250

251251
project.mirror_pull()
252252

253+
Get a project’s pull mirror details (EE edition)::
254+
255+
mirror_pull_details = project.mirror_pull_details()
256+
253257
Import / Export
254258
===============
255259

‎gitlab/v4/objects/projects.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,29 @@ def mirror_pull(self, **kwargs: Any) -> None:
579579
path=f"/projects/{self.encoded_id}/mirror/pull"
580580
self.manager.gitlab.http_post(path,**kwargs)
581581

582+
@cli.register_custom_action("Project")
583+
@exc.on_http_error(exc.GitlabGetError)
584+
defmirror_pull_details(self,**kwargs:Any)->Dict[str,Any]:
585+
"""Get a project's pull mirror details.
586+
587+
Introduced in GitLab 15.5.
588+
589+
Args:
590+
**kwargs: Extra options to send to the server (e.g. sudo)
591+
592+
Raises:
593+
GitlabAuthenticationError: If authentication is not correct
594+
GitlabGetError: If the server failed to perform the request
595+
596+
Returns:
597+
dict of the parsed json returned by the server
598+
"""
599+
path=f"/projects/{self.encoded_id}/mirror/pull"
600+
result=self.manager.gitlab.http_get(path,**kwargs)
601+
ifTYPE_CHECKING:
602+
assertisinstance(result,dict)
603+
returnresult
604+
582605
@cli.register_custom_action("Project", ("to_namespace",))
583606
@exc.on_http_error(exc.GitlabTransferProjectError)
584607
deftransfer(self,to_namespace:Union[int,str],**kwargs:Any)->None:

‎tests/unit/objects/test_projects.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,27 @@ def resp_start_pull_mirroring_project():
530530
yieldrsps
531531

532532

533+
@pytest.fixture
534+
defresp_pull_mirror_details_project():
535+
withresponses.RequestsMock()asrsps:
536+
rsps.add(
537+
method=responses.GET,
538+
url="http://localhost/api/v4/projects/1/mirror/pull",
539+
json={
540+
"id":101486,
541+
"last_error":None,
542+
"last_successful_update_at":"2020-01-06T17:32:02.823Z",
543+
"last_update_at":"2020-01-06T17:32:02.823Z",
544+
"last_update_started_at":"2020-01-06T17:31:55.864Z",
545+
"update_status":"finished",
546+
"url":"https://*****:*****@gitlab.com/gitlab-org/security/gitlab.git",
547+
},
548+
content_type="application/json",
549+
status=200,
550+
)
551+
yieldrsps
552+
553+
533554
@pytest.fixture
534555
defresp_snapshot_project():
535556
withresponses.RequestsMock()asrsps:
@@ -766,6 +787,12 @@ def test_project_pull_mirror(project, resp_start_pull_mirroring_project):
766787
project.mirror_pull()
767788

768789

790+
deftest_project_pull_mirror_details(project,resp_pull_mirror_details_project):
791+
details=project.mirror_pull_details()
792+
assertdetails["last_error"]isNone
793+
assertdetails["update_status"]=="finished"
794+
795+
769796
deftest_project_restore(project,resp_restore_project):
770797
project.restore()
771798

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp