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

Commit8867ee5

Browse files
nejchJohnVillalovos
authored andcommitted
feat(objects): support get project storage endpoint
1 parent792cee9 commit8867ee5

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed

‎docs/gl_objects/projects.rst‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,3 +783,30 @@ Get all additional statistics of a project::
783783
Get total fetches in last 30 days of a project::
784784

785785
total_fetches = project.additionalstatistics.get().fetches['total']
786+
787+
Project storage
788+
=============================
789+
790+
This endpoint requires admin access.
791+
792+
Reference
793+
---------
794+
795+
* v4 API:
796+
797+
+:class:`gitlab.v4.objects.ProjectStorage`
798+
+:class:`gitlab.v4.objects.ProjectStorageManager`
799+
+:attr:`gitlab.v4.objects.Project.storage`
800+
801+
* GitLab API: https://docs.gitlab.com/ee/api/projects.html#get-the-path-to-repository-storage
802+
803+
Examples
804+
---------
805+
806+
Get the repository storage details for a project::
807+
808+
storage = project.storage.get()
809+
810+
Get the repository storage disk path::
811+
812+
disk_path = project.storage.get().disk_path

‎gitlab/v4/objects/projects.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
fromgitlab.mixinsimport (
1010
CreateMixin,
1111
CRUDMixin,
12+
GetWithoutIdMixin,
1213
ListMixin,
1314
ObjectDeleteMixin,
1415
RefreshMixin,
@@ -80,6 +81,8 @@
8081
"ProjectForkManager",
8182
"ProjectRemoteMirror",
8283
"ProjectRemoteMirrorManager",
84+
"ProjectStorage",
85+
"ProjectStorageManager",
8386
]
8487

8588

@@ -180,6 +183,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO
180183
runners:ProjectRunnerManager
181184
services:ProjectServiceManager
182185
snippets:ProjectSnippetManager
186+
storage:"ProjectStorageManager"
183187
tags:ProjectTagManager
184188
triggers:ProjectTriggerManager
185189
users:ProjectUserManager
@@ -1013,3 +1017,18 @@ class ProjectRemoteMirrorManager(ListMixin, CreateMixin, UpdateMixin, RESTManage
10131017
required=("url",),optional=("enabled","only_protected_branches")
10141018
)
10151019
_update_attrs=RequiredOptional(optional=("enabled","only_protected_branches"))
1020+
1021+
1022+
classProjectStorage(RefreshMixin,RESTObject):
1023+
pass
1024+
1025+
1026+
classProjectStorageManager(GetWithoutIdMixin,RESTManager):
1027+
_path="/projects/{project_id}/storage"
1028+
_obj_cls=ProjectStorage
1029+
_from_parent_attrs= {"project_id":"id"}
1030+
1031+
defget(
1032+
self,id:Optional[Union[int,str]]=None,**kwargs:Any
1033+
)->Optional[ProjectStorage]:
1034+
returncast(Optional[ProjectStorage],super().get(id=id,**kwargs))

‎tests/functional/api/test_projects.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
importpytest
44

55
importgitlab
6+
fromgitlab.v4.objects.projectsimportProjectStorage
67

78

89
deftest_create_project(gl,user):
@@ -285,6 +286,12 @@ def test_project_stars(project):
285286
assertproject.star_count==0
286287

287288

289+
deftest_project_storage(project):
290+
storage=project.storage.get()
291+
assertisinstance(storage,ProjectStorage)
292+
assertstorage.repository_storage=="default"
293+
294+
288295
deftest_project_tags(project,project_file):
289296
tag=project.tags.create({"tag_name":"v1.0","ref":"main"})
290297
assertlen(project.tags.list())==1

‎tests/unit/objects/test_projects.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
StarredProject,
1313
UserProject,
1414
)
15+
fromgitlab.v4.objects.projectsimportProjectStorage
1516

1617
project_content= {"name":"name","id":1}
1718
languages_content= {
@@ -49,6 +50,19 @@ def resp_get_project():
4950
yieldrsps
5051

5152

53+
@pytest.fixture
54+
defresp_get_project_storage():
55+
withresponses.RequestsMock()asrsps:
56+
rsps.add(
57+
method=responses.GET,
58+
url="http://localhost/api/v4/projects/1/storage",
59+
json={"project_id":1,"disk_path":"/disk/path"},
60+
content_type="application/json",
61+
status=200,
62+
)
63+
yieldrsps
64+
65+
5266
@pytest.fixture
5367
defresp_user_projects():
5468
withresponses.RequestsMock()asrsps:
@@ -256,6 +270,12 @@ def test_get_project_languages(project, resp_list_languages):
256270
assertcoffee_script==00.01
257271

258272

273+
deftest_get_project_storage(project,resp_get_project_storage):
274+
storage=project.storage.get()
275+
assertisinstance(storage,ProjectStorage)
276+
assertstorage.disk_path=="/disk/path"
277+
278+
259279
@pytest.mark.skip(reason="missing test")
260280
deftest_archive_project(gl):
261281
pass

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp