| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,7 +8,11 @@ | |||
| 8 | 8 | import pytest | |
| 9 | 9 | import responses | |
| 10 | 10 | ||
| 11 | - from gitlab.v4.objects.audit_events import AuditEvent, ProjectAudit | ||
| 11 | + from gitlab.v4.objects.audit_events import ( | ||
| 12 | + AuditEvent, | ||
| 13 | + GroupAuditEvent, | ||
| 14 | + ProjectAuditEvent, | ||
| 15 | + ) | ||
| 12 | 16 | ||
| 13 | 17 | id = 5 | |
| 14 | 18 | ||
@@ -79,14 +83,27 @@ def test_get_instance_audit_events(gl, resp_get_audit_event): | |||
| 79 | 83 | assert audit_event.id == id | |
| 80 | 84 | ||
| 81 | 85 | ||
| 86 | + def test_list_group_audit_events(group, resp_list_audit_events): | ||
| 87 | + audit_events = group.audit_events.list() | ||
| 88 | + assert isinstance(audit_events, list) | ||
| 89 | + assert isinstance(audit_events[0], GroupAuditEvent) | ||
| 90 | + assert audit_events[0].id == id | ||
| 91 | + | ||
| 92 | + | ||
| 93 | + def test_get_group_audit_events(group, resp_get_audit_event): | ||
| 94 | + audit_event = group.audit_events.get(id) | ||
| 95 | + assert isinstance(audit_event, GroupAuditEvent) | ||
| 96 | + assert audit_event.id == id | ||
| 97 | + | ||
| 98 | + | ||
| 82 | 99 | def test_list_project_audit_events(project, resp_list_audit_events): | |
| 83 | 100 | audit_events = project.audit_events.list() | |
| 84 | 101 | assert isinstance(audit_events, list) | |
| 85 | - assert isinstance(audit_events[0], ProjectAudit) | ||
| 102 | + assert isinstance(audit_events[0], ProjectAuditEvent) | ||
| 86 | 103 | assert audit_events[0].id == id | |
| 87 | 104 | ||
| 88 | 105 | ||
| 89 | 106 | def test_get_project_audit_events(project, resp_get_audit_event): | |
| 90 | 107 | audit_event = project.audit_events.get(id) | |
| 91 | - assert isinstance(audit_event, ProjectAudit) | ||
| 108 | + assert isinstance(audit_event, ProjectAuditEvent) | ||
| 92 | 109 | assert audit_event.id == id | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2,13 +2,18 @@ | |||
| 2 | 2 | GitLab API: | |
| 3 | 3 | https://docs.gitlab.com/ee/api/audit_events.html | |
| 4 | 4 | """ | |
| 5 | + import warnings | ||
| 5 | 6 | ||
| 6 | 7 | from gitlab.base import RESTManager, RESTObject | |
| 7 | 8 | from gitlab.mixins import RetrieveMixin | |
| 8 | 9 | ||
| 9 | 10 | __all__ = [ | |
| 10 | 11 | "AuditEvent", | |
| 11 | 12 | "AuditEventManager", | |
| 13 | + "GroupAuditEvent", | ||
| 14 | + "GroupAuditEventManager", | ||
| 15 | + "ProjectAuditEvent", | ||
| 16 | + "ProjectAuditEventManager", | ||
| 12 | 17 | "ProjectAudit", | |
| 13 | 18 | "ProjectAuditManager", | |
| 14 | 19 | ] | |
@@ -24,12 +29,47 @@ class AuditEventManager(RetrieveMixin, RESTManager): | |||
| 24 | 29 | _list_filters = ("created_after", "created_before", "entity_type", "entity_id") | |
| 25 | 30 | ||
| 26 | 31 | ||
| 27 | - class ProjectAudit(RESTObject): | ||
| 32 | + class GroupAuditEvent(RESTObject): | ||
| 28 | 33 | _id_attr = "id" | |
| 29 | 34 | ||
| 30 | 35 | ||
| 31 | - class ProjectAuditManager(RetrieveMixin, RESTManager): | ||
| 36 | + class GroupAuditEventManager(RetrieveMixin, RESTManager): | ||
| 37 | + _path = "/groups/%(group_id)s/audit_events" | ||
| 38 | + _obj_cls = GroupAuditEvent | ||
| 39 | + _from_parent_attrs = {"group_id": "id"} | ||
| 40 | + _list_filters = ("created_after", "created_before") | ||
| 41 | + | ||
| 42 | + | ||
| 43 | + class ProjectAuditEvent(RESTObject): | ||
| 44 | + _id_attr = "id" | ||
| 45 | + | ||
| 46 | + def __init_subclass__(self): | ||
| 47 | + warnings.warn( | ||
| 48 | + "This class has been renamed to ProjectAuditEvent " | ||
| 49 | + "and will be removed in a future release.", | ||
| 50 | + DeprecationWarning, | ||
| 51 | + 2, | ||
| 52 | + ) | ||
| 53 | + | ||
| 54 | + | ||
| 55 | + class ProjectAuditEventManager(RetrieveMixin, RESTManager): | ||
| 32 | 56 | _path = "/projects/%(project_id)s/audit_events" | |
| 33 | - _obj_cls = ProjectAudit | ||
| 57 | + _obj_cls = ProjectAuditEvent | ||
| 34 | 58 | _from_parent_attrs = {"project_id": "id"} | |
| 35 | 59 | _list_filters = ("created_after", "created_before") | |
| 60 | + | ||
| 61 | + def __init_subclass__(self): | ||
| 62 | + warnings.warn( | ||
| 63 | + "This class has been renamed to ProjectAuditEventManager " | ||
| 64 | + "and will be removed in a future release.", | ||
| 65 | + DeprecationWarning, | ||
| 66 | + 2, | ||
| 67 | + ) | ||
| 68 | + | ||
| 69 | + | ||
| 70 | + class ProjectAudit(ProjectAuditEvent): | ||
| 71 | + pass | ||
| 72 | + | ||
| 73 | + | ||
| 74 | + class ProjectAuditManager(ProjectAuditEventManager): | ||
| 75 | + pass | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,7 @@ | |||
| 3 | 3 | from gitlab.base import RESTManager, RESTObject | |
| 4 | 4 | from gitlab.mixins import CRUDMixin, ListMixin, ObjectDeleteMixin, SaveMixin | |
| 5 | 5 | from .access_requests import GroupAccessRequestManager | |
| 6 | + from .audit_events import GroupAuditEventManager | ||
| 6 | 7 | from .badges import GroupBadgeManager | |
| 7 | 8 | from .boards import GroupBoardManager | |
| 8 | 9 | from .custom_attributes import GroupCustomAttributeManager | |
@@ -34,6 +35,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject): | |||
| 34 | 35 | _short_print_attr = "name" | |
| 35 | 36 | _managers = ( | |
| 36 | 37 | ("accessrequests", "GroupAccessRequestManager"), | |
| 38 | + ("audit_events", "GroupAuditEventManager"), | ||
| 37 | 39 | ("badges", "GroupBadgeManager"), | |
| 38 | 40 | ("boards", "GroupBoardManager"), | |
| 39 | 41 | ("customattributes", "GroupCustomAttributeManager"), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,7 +25,7 @@ | |||
| 25 | 25 | from .deployments import ProjectDeploymentManager | |
| 26 | 26 | from .environments import ProjectEnvironmentManager | |
| 27 | 27 | from .events import ProjectEventManager | |
| 28 | - from .audit_events import ProjectAuditManager | ||
| 28 | + from .audit_events import ProjectAuditEventManager | ||
| 29 | 29 | from .export_import import ProjectExportManager, ProjectImportManager | |
| 30 | 30 | from .files import ProjectFileManager | |
| 31 | 31 | from .hooks import ProjectHookManager | |
@@ -117,7 +117,7 @@ class Project(RefreshMixin, SaveMixin, ObjectDeleteMixin, RepositoryMixin, RESTO | |||
| 117 | 117 | ("deployments", "ProjectDeploymentManager"), | |
| 118 | 118 | ("environments", "ProjectEnvironmentManager"), | |
| 119 | 119 | ("events", "ProjectEventManager"), | |
| 120 | - ("audit_events", "ProjectAuditManager"), | ||
| 120 | + ("audit_events", "ProjectAuditEventManager"), | ||
| 121 | 121 | ("exports", "ProjectExportManager"), | |
| 122 | 122 | ("files", "ProjectFileManager"), | |
| 123 | 123 | ("forks", "ProjectForkManager"), | |
| Back | FazBrowse Home | New Git URL |
0 commit comments