| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c84379d commit 70148c6
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,6 +20,10 @@ Get the list of container registry repositories associated with the project:: | |||
| 20 | 20 | ||
| 21 | 21 | repositories = project.repositories.list() | |
| 22 | 22 | ||
| 23 | + Get the list of all project container registry repositories in a group:: | ||
| 24 | + | ||
| 25 | + repositories = group.registry_repositories.list() | ||
| 26 | + | ||
| 23 | 27 | Delete repository:: | |
| 24 | 28 | ||
| 25 | 29 | project.repositories.delete(id=x) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,7 @@ | |||
| 6 | 6 | from gitlab.mixins import DeleteMixin, ListMixin, ObjectDeleteMixin, RetrieveMixin | |
| 7 | 7 | ||
| 8 | 8 | __all__ = [ | |
| 9 | + "GroupRegistryRepositoryManager", | ||
| 9 | 10 | "ProjectRegistryRepository", | |
| 10 | 11 | "ProjectRegistryRepositoryManager", | |
| 11 | 12 | "ProjectRegistryTag", | |
@@ -65,3 +66,9 @@ def get( | |||
| 65 | 66 | self, id: Union[str, int], lazy: bool = False, **kwargs: Any | |
| 66 | 67 | ) -> ProjectRegistryTag: | |
| 67 | 68 | return cast(ProjectRegistryTag, super().get(id=id, lazy=lazy, **kwargs)) | |
| 69 | + | ||
| 70 | + | ||
| 71 | + class GroupRegistryRepositoryManager(ListMixin, RESTManager): | ||
| 72 | + _path = "/groups/{group_id}/registry/repositories" | ||
| 73 | + _obj_cls = ProjectRegistryRepository | ||
| 74 | + _from_parent_attrs = {"group_id": "id"} | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,6 +15,7 @@ | |||
| 15 | 15 | from .badges import GroupBadgeManager # noqa: F401 | |
| 16 | 16 | from .boards import GroupBoardManager # noqa: F401 | |
| 17 | 17 | from .clusters import GroupClusterManager # noqa: F401 | |
| 18 | + from .container_registry import GroupRegistryRepositoryManager # noqa: F401 | ||
| 18 | 19 | from .custom_attributes import GroupCustomAttributeManager # noqa: F401 | |
| 19 | 20 | from .deploy_tokens import GroupDeployTokenManager # noqa: F401 | |
| 20 | 21 | from .epics import GroupEpicManager # noqa: F401 | |
@@ -77,6 +78,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject): | |||
| 77 | 78 | packages: GroupPackageManager | |
| 78 | 79 | projects: GroupProjectManager | |
| 79 | 80 | pushrules: GroupPushRulesManager | |
| 81 | + registry_repositories: GroupRegistryRepositoryManager | ||
| 80 | 82 | runners: GroupRunnerManager | |
| 81 | 83 | subgroups: "GroupSubgroupManager" | |
| 82 | 84 | variables: GroupVariableManager | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,47 @@ | |||
| 1 | + """ | ||
| 2 | + GitLab API: https://docs.gitlab.com/ee/api/container_registry.html | ||
| 3 | + """ | ||
| 4 | + import pytest | ||
| 5 | + import responses | ||
| 6 | + | ||
| 7 | + from gitlab.v4.objects import ProjectRegistryRepository | ||
| 8 | + | ||
| 9 | + repositories_content = [ | ||
| 10 | + { | ||
| 11 | + "id": 1, | ||
| 12 | + "name": "", | ||
| 13 | + "path": "group/project", | ||
| 14 | + "project_id": 9, | ||
| 15 | + "location": "gitlab.example.com:5000/group/project", | ||
| 16 | + "created_at": "2019-01-10T13:38:57.391Z", | ||
| 17 | + "cleanup_policy_started_at": "2020-01-10T15:40:57.391Z", | ||
| 18 | + }, | ||
| 19 | + { | ||
| 20 | + "id": 2, | ||
| 21 | + "name": "releases", | ||
| 22 | + "path": "group/project/releases", | ||
| 23 | + "project_id": 9, | ||
| 24 | + "location": "gitlab.example.com:5000/group/project/releases", | ||
| 25 | + "created_at": "2019-01-10T13:39:08.229Z", | ||
| 26 | + "cleanup_policy_started_at": "2020-08-17T03:12:35.489Z", | ||
| 27 | + }, | ||
| 28 | + ] | ||
| 29 | + | ||
| 30 | + | ||
| 31 | + @pytest.fixture | ||
| 32 | + def resp_group_registry_repositories(): | ||
| 33 | + with responses.RequestsMock() as rsps: | ||
| 34 | + rsps.add( | ||
| 35 | + method=responses.GET, | ||
| 36 | + url="http://localhost/api/v4/groups/1/registry/repositories", | ||
| 37 | + json=repositories_content, | ||
| 38 | + content_type="application/json", | ||
| 39 | + status=200, | ||
| 40 | + ) | ||
| 41 | + yield rsps | ||
| 42 | + | ||
| 43 | + | ||
| 44 | + def test_list_group_registry_repositories(group, resp_group_registry_repositories): | ||
| 45 | + repositories = group.registry_repositories.list() | ||
| 46 | + assert isinstance(repositories[0], ProjectRegistryRepository) | ||
| 47 | + assert repositories[0].id == 1 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments