1from gitlab.base import RequiredOptional, RESTManager, RESTObject
2from gitlab.mixins import (
3    CreateMixin,
4    DeleteMixin,
5    GetWithoutIdMixin,
6    ObjectDeleteMixin,
7    SaveMixin,
8    UpdateMixin,
9)
10
11__all__ = [
12    "ProjectPushRules",
13    "ProjectPushRulesManager",
14]
15
16
17class ProjectPushRules(SaveMixin, ObjectDeleteMixin, RESTObject):
18    _id_attr = None
19
20
21class ProjectPushRulesManager(
22    GetWithoutIdMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTManager
23):
24    _path = "/projects/%(project_id)s/push_rule"
25    _obj_cls = ProjectPushRules
26    _from_parent_attrs = {"project_id": "id"}
27    _create_attrs = RequiredOptional(
28        optional=(
29            "deny_delete_tag",
30            "member_check",
31            "prevent_secrets",
32            "commit_message_regex",
33            "branch_name_regex",
34            "author_email_regex",
35            "file_name_regex",
36            "max_file_size",
37        ),
38    )
39    _update_attrs = RequiredOptional(
40        optional=(
41            "deny_delete_tag",
42            "member_check",
43            "prevent_secrets",
44            "commit_message_regex",
45            "branch_name_regex",
46            "author_email_regex",
47            "file_name_regex",
48            "max_file_size",
49        ),
50    )
51