| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 792cee9 commit 8867ee5
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -783,3 +783,30 @@ Get all additional statistics of a project:: | |||
| 783 | 783 | Get total fetches in last 30 days of a project:: | |
| 784 | 784 | ||
| 785 | 785 | 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 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,7 @@ | |||
| 9 | 9 | from gitlab.mixins import ( | |
| 10 | 10 | CreateMixin, | |
| 11 | 11 | CRUDMixin, | |
| 12 | + GetWithoutIdMixin, | ||
| 12 | 13 | ListMixin, | |
| 13 | 14 | ObjectDeleteMixin, | |
| 14 | 15 | RefreshMixin, | |
@@ -80,6 +81,8 @@ | |||
| 80 | 81 | "ProjectForkManager", | |
| 81 | 82 | "ProjectRemoteMirror", | |
| 82 | 83 | "ProjectRemoteMirrorManager", | |
| 84 | + "ProjectStorage", | ||
| 85 | + "ProjectStorageManager", | ||
| 83 | 86 | ] | |
| 84 | 87 | ||
| 85 | 88 | ||
@@ -180,6 +183,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO | |||
| 180 | 183 | runners: ProjectRunnerManager | |
| 181 | 184 | services: ProjectServiceManager | |
| 182 | 185 | snippets: ProjectSnippetManager | |
| 186 | + storage: "ProjectStorageManager" | ||
| 183 | 187 | tags: ProjectTagManager | |
| 184 | 188 | triggers: ProjectTriggerManager | |
| 185 | 189 | users: ProjectUserManager | |
@@ -1013,3 +1017,18 @@ class ProjectRemoteMirrorManager(ListMixin, CreateMixin, UpdateMixin, RESTManage | |||
| 1013 | 1017 | required=("url",), optional=("enabled", "only_protected_branches") | |
| 1014 | 1018 | ) | |
| 1015 | 1019 | _update_attrs = RequiredOptional(optional=("enabled", "only_protected_branches")) | |
| 1020 | + | ||
| 1021 | + | ||
| 1022 | + class ProjectStorage(RefreshMixin, RESTObject): | ||
| 1023 | + pass | ||
| 1024 | + | ||
| 1025 | + | ||
| 1026 | + class ProjectStorageManager(GetWithoutIdMixin, RESTManager): | ||
| 1027 | + _path = "/projects/{project_id}/storage" | ||
| 1028 | + _obj_cls = ProjectStorage | ||
| 1029 | + _from_parent_attrs = {"project_id": "id"} | ||
| 1030 | + | ||
| 1031 | + def get( | ||
| 1032 | + self, id: Optional[Union[int, str]] = None, **kwargs: Any | ||
| 1033 | + ) -> Optional[ProjectStorage]: | ||
| 1034 | + return cast(Optional[ProjectStorage], super().get(id=id, **kwargs)) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,7 @@ | |||
| 3 | 3 | import pytest | |
| 4 | 4 | ||
| 5 | 5 | import gitlab | |
| 6 | + from gitlab.v4.objects.projects import ProjectStorage | ||
| 6 | 7 | ||
| 7 | 8 | ||
| 8 | 9 | def test_create_project(gl, user): | |
@@ -285,6 +286,12 @@ def test_project_stars(project): | |||
| 285 | 286 | assert project.star_count == 0 | |
| 286 | 287 | ||
| 287 | 288 | ||
| 289 | + def test_project_storage(project): | ||
| 290 | + storage = project.storage.get() | ||
| 291 | + assert isinstance(storage, ProjectStorage) | ||
| 292 | + assert storage.repository_storage == "default" | ||
| 293 | + | ||
| 294 | + | ||
| 288 | 295 | def test_project_tags(project, project_file): | |
| 289 | 296 | tag = project.tags.create({"tag_name": "v1.0", "ref": "main"}) | |
| 290 | 297 | assert len(project.tags.list()) == 1 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,6 +12,7 @@ | |||
| 12 | 12 | StarredProject, | |
| 13 | 13 | UserProject, | |
| 14 | 14 | ) | |
| 15 | + from gitlab.v4.objects.projects import ProjectStorage | ||
| 15 | 16 | ||
| 16 | 17 | project_content = {"name": "name", "id": 1} | |
| 17 | 18 | languages_content = { | |
@@ -49,6 +50,19 @@ def resp_get_project(): | |||
| 49 | 50 | yield rsps | |
| 50 | 51 | ||
| 51 | 52 | ||
| 53 | + @pytest.fixture | ||
| 54 | + def resp_get_project_storage(): | ||
| 55 | + with responses.RequestsMock() as rsps: | ||
| 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 | + yield rsps | ||
| 64 | + | ||
| 65 | + | ||
| 52 | 66 | @pytest.fixture | |
| 53 | 67 | def resp_user_projects(): | |
| 54 | 68 | with responses.RequestsMock() as rsps: | |
@@ -256,6 +270,12 @@ def test_get_project_languages(project, resp_list_languages): | |||
| 256 | 270 | assert coffee_script == 00.01 | |
| 257 | 271 | ||
| 258 | 272 | ||
| 273 | + def test_get_project_storage(project, resp_get_project_storage): | ||
| 274 | + storage = project.storage.get() | ||
| 275 | + assert isinstance(storage, ProjectStorage) | ||
| 276 | + assert storage.disk_path == "/disk/path" | ||
| 277 | + | ||
| 278 | + | ||
| 259 | 279 | @pytest.mark.skip(reason="missing test") | |
| 260 | 280 | def test_archive_project(gl): | |
| 261 | 281 | pass | |
| Back | FazBrowse Home | New Git URL |
0 commit comments