summaryrefslogtreecommitdiff
path: root/gitlab/v4
diff options
context:
space:
mode:
Diffstat (limited to 'gitlab/v4')
-rw-r--r--gitlab/v4/cli.py5
-rw-r--r--gitlab/v4/objects.py22
2 files changed, 25 insertions, 2 deletions
diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py
index 0e50de1..451bec8 100644
--- a/gitlab/v4/cli.py
+++ b/gitlab/v4/cli.py
@@ -143,8 +143,9 @@ def _populate_sub_parser_by_class(cls, sub_parser):
action='store_true')
if action_name == 'delete':
- id_attr = cls._id_attr.replace('_', '-')
- sub_parser_action.add_argument("--%s" % id_attr, required=True)
+ if cls._id_attr is not None:
+ id_attr = cls._id_attr.replace('_', '-')
+ sub_parser_action.add_argument("--%s" % id_attr, required=True)
if action_name == "get":
if gitlab.mixins.GetWithoutIdMixin not in inspect.getmro(cls):
diff --git a/gitlab/v4/objects.py b/gitlab/v4/objects.py
index 856d74a..2db2e39 100644
--- a/gitlab/v4/objects.py
+++ b/gitlab/v4/objects.py
@@ -2459,6 +2459,27 @@ class ProjectPipelineScheduleManager(CRUDMixin, RESTManager):
('description', 'ref', 'cron', 'cron_timezone', 'active'))
+class ProjectPushRules(SaveMixin, ObjectDeleteMixin, RESTObject):
+ _id_attr = None
+
+
+class ProjectPushRulesManager(GetWithoutIdMixin, CreateMixin, UpdateMixin,
+ DeleteMixin, RESTManager):
+ _path = '/projects/%(project_id)s/push_rule'
+ _obj_cls = ProjectPushRules
+ _from_parent_attrs = {'project_id': 'id'}
+ _create_attrs = (tuple(),
+ ('deny_delete_tag', 'member_check',
+ 'prevent_secrets', 'commit_message_regex',
+ 'branch_name_regex', 'author_email_regex',
+ 'file_name_regex', 'max_file_size'))
+ _update_attrs = (tuple(),
+ ('deny_delete_tag', 'member_check',
+ 'prevent_secrets', 'commit_message_regex',
+ 'branch_name_regex', 'author_email_regex',
+ 'file_name_regex', 'max_file_size'))
+
+
class ProjectSnippetNoteAwardEmoji(ObjectDeleteMixin, RESTObject):
pass
@@ -2887,6 +2908,7 @@ class Project(SaveMixin, ObjectDeleteMixin, RESTObject):
('pipelines', 'ProjectPipelineManager'),
('protectedbranches', 'ProjectProtectedBranchManager'),
('pipelineschedules', 'ProjectPipelineScheduleManager'),
+ ('pushrules', 'ProjectPushRulesManager'),
('runners', 'ProjectRunnerManager'),
('services', 'ProjectServiceManager'),
('snippets', 'ProjectSnippetManager'),