Loading docs/gl_objects/groups.rst +21 −0 Original line number Diff line number Diff line Loading @@ -458,3 +458,24 @@ Edit group push rules:: Delete group push rules:: pr.delete() Group Service Account ===================== Reference --------- * v4 API: + :class:`gitlab.v4.objects.GroupServiceAccount` + :class:`gitlab.v4.objects.GroupServiceAccountManager` + :attr:`gitlab.v4.objects.Group.serviceaccounts` * GitLab API: https://docs.gitlab.com/ee/api/groups.html#service-accounts Examples --------- Create group service account (only allowed at top level group):: group.serviceaccount.create({'name': 'group-service-account', 'username': 'group-service-account'}) gitlab/v4/objects/__init__.py +1 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ from .resource_groups import * from .reviewers import * from .runners import * from .secure_files import * from .service_accounts import * from .settings import * from .sidekiq import * from .snippets import * Loading gitlab/v4/objects/groups.py +2 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ from .packages import GroupPackageManager # noqa: F401 from .projects import GroupProjectManager, SharedProjectManager # noqa: F401 from .push_rules import GroupPushRulesManager from .runners import GroupRunnerManager # noqa: F401 from .service_accounts import GroupServiceAccountManager # noqa: F401 from .statistics import GroupIssuesStatisticsManager # noqa: F401 from .variables import GroupVariableManager # noqa: F401 from .wikis import GroupWikiManager # noqa: F401 Loading Loading @@ -102,6 +103,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject): variables: GroupVariableManager wikis: GroupWikiManager saml_group_links: "GroupSAMLGroupLinkManager" service_accounts: "GroupServiceAccountManager" @cli.register_custom_action("Group", ("project_id",)) @exc.on_http_error(exc.GitlabTransferProjectError) Loading gitlab/v4/objects/service_accounts.py 0 → 100644 +18 −0 Original line number Diff line number Diff line from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CreateMixin from gitlab.types import RequiredOptional __all__ = ["GroupServiceAccount", "GroupServiceAccountManager"] class GroupServiceAccount(RESTObject): pass class GroupServiceAccountManager(CreateMixin, RESTManager): _path = "/groups/{group_id}/service_accounts" _obj_cls = GroupServiceAccount _from_parent_attrs = {"group_id": "id"} _create_attrs = RequiredOptional( optional=("name", "username"), ) tests/functional/api/test_groups.py +9 −0 Original line number Diff line number Diff line Loading @@ -308,3 +308,12 @@ def test_group_saml_group_links(group): group.saml_group_links.create( {"saml_group_name": "saml-group-1", "access_level": 10} ) @pytest.mark.gitlab_premium def test_group_service_account(group): service_account = group.service_accounts.create( {"name": "gitlab-service-account", "username": "gitlab-service-account"} ) assert service_account.name == "gitlab-service-account" assert service_account.username == "gitlab-service-account" Loading
docs/gl_objects/groups.rst +21 −0 Original line number Diff line number Diff line Loading @@ -458,3 +458,24 @@ Edit group push rules:: Delete group push rules:: pr.delete() Group Service Account ===================== Reference --------- * v4 API: + :class:`gitlab.v4.objects.GroupServiceAccount` + :class:`gitlab.v4.objects.GroupServiceAccountManager` + :attr:`gitlab.v4.objects.Group.serviceaccounts` * GitLab API: https://docs.gitlab.com/ee/api/groups.html#service-accounts Examples --------- Create group service account (only allowed at top level group):: group.serviceaccount.create({'name': 'group-service-account', 'username': 'group-service-account'})
gitlab/v4/objects/__init__.py +1 −0 Original line number Diff line number Diff line Loading @@ -59,6 +59,7 @@ from .resource_groups import * from .reviewers import * from .runners import * from .secure_files import * from .service_accounts import * from .settings import * from .sidekiq import * from .snippets import * Loading
gitlab/v4/objects/groups.py +2 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ from .packages import GroupPackageManager # noqa: F401 from .projects import GroupProjectManager, SharedProjectManager # noqa: F401 from .push_rules import GroupPushRulesManager from .runners import GroupRunnerManager # noqa: F401 from .service_accounts import GroupServiceAccountManager # noqa: F401 from .statistics import GroupIssuesStatisticsManager # noqa: F401 from .variables import GroupVariableManager # noqa: F401 from .wikis import GroupWikiManager # noqa: F401 Loading Loading @@ -102,6 +103,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject): variables: GroupVariableManager wikis: GroupWikiManager saml_group_links: "GroupSAMLGroupLinkManager" service_accounts: "GroupServiceAccountManager" @cli.register_custom_action("Group", ("project_id",)) @exc.on_http_error(exc.GitlabTransferProjectError) Loading
gitlab/v4/objects/service_accounts.py 0 → 100644 +18 −0 Original line number Diff line number Diff line from gitlab.base import RESTManager, RESTObject from gitlab.mixins import CreateMixin from gitlab.types import RequiredOptional __all__ = ["GroupServiceAccount", "GroupServiceAccountManager"] class GroupServiceAccount(RESTObject): pass class GroupServiceAccountManager(CreateMixin, RESTManager): _path = "/groups/{group_id}/service_accounts" _obj_cls = GroupServiceAccount _from_parent_attrs = {"group_id": "id"} _create_attrs = RequiredOptional( optional=("name", "username"), )
tests/functional/api/test_groups.py +9 −0 Original line number Diff line number Diff line Loading @@ -308,3 +308,12 @@ def test_group_saml_group_links(group): group.saml_group_links.create( {"saml_group_name": "saml-group-1", "access_level": 10} ) @pytest.mark.gitlab_premium def test_group_service_account(group): service_account = group.service_accounts.create( {"name": "gitlab-service-account", "username": "gitlab-service-account"} ) assert service_account.name == "gitlab-service-account" assert service_account.username == "gitlab-service-account"