diff options
| author | O'Keefe, Gerard (Gerry) <gokeefe@atb.com> | 2022-07-04 10:54:51 -0700 |
|---|---|---|
| committer | John L. Villalovos <john@sodarock.com> | 2022-07-04 10:54:51 -0700 |
| commit | b5cdc097005c8a48a16e793a69c343198b14e035 (patch) | |
| tree | 972c6a46ccb6effee32a96453b90beb2138ef545 /gitlab | |
| parent | 3df404c8165c36486bbcdf03816bd0b3173d9de8 (diff) | |
| download | gitlab-b5cdc097005c8a48a16e793a69c343198b14e035.tar.gz | |
feat: add support for group push rules
Add the GroupPushRules and GroupPushRulesManager classes.
Closes: #1259
Diffstat (limited to 'gitlab')
| -rw-r--r-- | gitlab/v4/objects/groups.py | 2 | ||||
| -rw-r--r-- | gitlab/v4/objects/push_rules.py | 57 |
2 files changed, 57 insertions, 2 deletions
diff --git a/gitlab/v4/objects/groups.py b/gitlab/v4/objects/groups.py index 8cb5052..84fd600 100644 --- a/gitlab/v4/objects/groups.py +++ b/gitlab/v4/objects/groups.py @@ -33,6 +33,7 @@ from .milestones import GroupMilestoneManager # noqa: F401 from .notification_settings import GroupNotificationSettingsManager # noqa: F401 from .packages import GroupPackageManager # noqa: F401 from .projects import GroupProjectManager # noqa: F401 +from .push_rules import GroupPushRulesManager from .runners import GroupRunnerManager # noqa: F401 from .statistics import GroupIssuesStatisticsManager # noqa: F401 from .variables import GroupVariableManager # noqa: F401 @@ -75,6 +76,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject): notificationsettings: GroupNotificationSettingsManager packages: GroupPackageManager projects: GroupProjectManager + pushrules: GroupPushRulesManager runners: GroupRunnerManager subgroups: "GroupSubgroupManager" variables: GroupVariableManager diff --git a/gitlab/v4/objects/push_rules.py b/gitlab/v4/objects/push_rules.py index d1fe81c..9b4980b 100644 --- a/gitlab/v4/objects/push_rules.py +++ b/gitlab/v4/objects/push_rules.py @@ -12,6 +12,8 @@ from gitlab.mixins import ( from gitlab.types import RequiredOptional __all__ = [ + "GroupPushRules", + "GroupPushRulesManager", "ProjectPushRules", "ProjectPushRulesManager", ] @@ -29,14 +31,62 @@ class ProjectPushRulesManager( _from_parent_attrs = {"project_id": "id"} _create_attrs = RequiredOptional( optional=( + "author_email_regex", + "branch_name_regex", + "commit_committer_check", + "commit_message_negative_regex", + "commit_message_regex", + "deny_delete_tag", + "file_name_regex", + "max_file_size", + "member_check", + "prevent_secrets", + "reject_unsigned_commits", + ), + ) + _update_attrs = RequiredOptional( + optional=( + "author_email_regex", + "branch_name_regex", + "commit_committer_check", + "commit_message_negative_regex", + "commit_message_regex", + "deny_delete_tag", + "file_name_regex", + "max_file_size", + "member_check", + "prevent_secrets", + "reject_unsigned_commits", + ), + ) + + def get(self, **kwargs: Any) -> ProjectPushRules: + return cast(ProjectPushRules, super().get(**kwargs)) + + +class GroupPushRules(SaveMixin, ObjectDeleteMixin, RESTObject): + _id_attr = None + + +class GroupPushRulesManager( + GetWithoutIdMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTManager +): + _path = "/groups/{group_id}/push_rule" + _obj_cls = GroupPushRules + _from_parent_attrs = {"group_id": "id"} + _create_attrs = RequiredOptional( + optional=( "deny_delete_tag", "member_check", "prevent_secrets", "commit_message_regex", + "commit_message_negative_regex", "branch_name_regex", "author_email_regex", "file_name_regex", "max_file_size", + "commit_committer_check", + "reject_unsigned_commits", ), ) _update_attrs = RequiredOptional( @@ -45,12 +95,15 @@ class ProjectPushRulesManager( "member_check", "prevent_secrets", "commit_message_regex", + "commit_message_negative_regex", "branch_name_regex", "author_email_regex", "file_name_regex", "max_file_size", + "commit_committer_check", + "reject_unsigned_commits", ), ) - def get(self, **kwargs: Any) -> ProjectPushRules: - return cast(ProjectPushRules, super().get(**kwargs)) + def get(self, **kwargs: Any) -> GroupPushRules: + return cast(GroupPushRules, super().get(**kwargs)) |
