| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 26c0441 commit 32c704c
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -250,6 +250,17 @@ def save(self, **kwargs): | |||
| 250 | 250 | self._update_attrs(server_data) | |
| 251 | 251 | ||
| 252 | 252 | ||
| 253 | + class ObjectDeleteMixin(object): | ||
| 254 | + """Mixin for RESTObject's that can be deleted.""" | ||
| 255 | + def delete(self, **kwargs): | ||
| 256 | + """Delete the object from the server. | ||
| 257 | + | ||
| 258 | + Args: | ||
| 259 | + **kwargs: Extra option to send to the server (e.g. sudo) | ||
| 260 | + """ | ||
| 261 | + self.manager.delete(self.get_id()) | ||
| 262 | + | ||
| 263 | + | ||
| 253 | 264 | class AccessRequestMixin(object): | |
| 254 | 265 | def approve(self, access_level=gitlab.DEVELOPER_ACCESS, **kwargs): | |
| 255 | 266 | """Approve an access request. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -62,7 +62,7 @@ def compound_metrics(self, **kwargs): | |||
| 62 | 62 | return self.gitlab.http_get('/sidekiq/compound_metrics', **kwargs) | |
| 63 | 63 | ||
| 64 | 64 | ||
| 65 | - class UserEmail(RESTObject): | ||
| 65 | + class UserEmail(ObjectDeleteMixin, RESTObject): | ||
| 66 | 66 | _short_print_attr = 'email' | |
| 67 | 67 | ||
| 68 | 68 | ||
@@ -73,7 +73,7 @@ class UserEmailManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTManager): | |||
| 73 | 73 | _create_attrs = (('email', ), tuple()) | |
| 74 | 74 | ||
| 75 | 75 | ||
| 76 | - class UserKey(RESTObject): | ||
| 76 | + class UserKey(ObjectDeleteMixin, RESTObject): | ||
| 77 | 77 | pass | |
| 78 | 78 | ||
| 79 | 79 | ||
@@ -101,7 +101,7 @@ class UserProjectManager(CreateMixin, RESTManager): | |||
| 101 | 101 | ) | |
| 102 | 102 | ||
| 103 | 103 | ||
| 104 | - class User(SaveMixin, RESTObject): | ||
| 104 | + class User(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 105 | 105 | _short_print_attr = 'username' | |
| 106 | 106 | _managers = ( | |
| 107 | 107 | ('emails', 'UserEmailManager'), | |
@@ -162,7 +162,7 @@ def _sanitize_data(self, data, action): | |||
| 162 | 162 | return new_data | |
| 163 | 163 | ||
| 164 | 164 | ||
| 165 | - class CurrentUserEmail(RESTObject): | ||
| 165 | + class CurrentUserEmail(ObjectDeleteMixin, RESTObject): | ||
| 166 | 166 | _short_print_attr = 'email' | |
| 167 | 167 | ||
| 168 | 168 | ||
@@ -173,7 +173,7 @@ class CurrentUserEmailManager(RetrieveMixin, CreateMixin, DeleteMixin, | |||
| 173 | 173 | _create_attrs = (('email', ), tuple()) | |
| 174 | 174 | ||
| 175 | 175 | ||
| 176 | - class CurrentUserKey(RESTObject): | ||
| 176 | + class CurrentUserKey(ObjectDeleteMixin, RESTObject): | ||
| 177 | 177 | _short_print_attr = 'title' | |
| 178 | 178 | ||
| 179 | 179 | ||
@@ -231,7 +231,7 @@ def _sanitize_data(self, data, action): | |||
| 231 | 231 | return new_data | |
| 232 | 232 | ||
| 233 | 233 | ||
| 234 | - class BroadcastMessage(SaveMixin, RESTObject): | ||
| 234 | + class BroadcastMessage(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 235 | 235 | pass | |
| 236 | 236 | ||
| 237 | 237 | ||
@@ -308,12 +308,12 @@ class GroupIssueManager(GetFromListMixin, RESTManager): | |||
| 308 | 308 | _list_filters = ('state', 'labels', 'milestone', 'order_by', 'sort') | |
| 309 | 309 | ||
| 310 | 310 | ||
| 311 | - class GroupMember(SaveMixin, RESTObject): | ||
| 311 | + class GroupMember(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 312 | 312 | _short_print_attr = 'username' | |
| 313 | 313 | ||
| 314 | 314 | ||
| 315 | 315 | class GroupMemberManager(GetFromListMixin, CreateMixin, UpdateMixin, | |
| 316 | - RESTManager): | ||
| 316 | + DeleteMixin, RESTManager): | ||
| 317 | 317 | _path = '/groups/%(group_id)s/members' | |
| 318 | 318 | _obj_cls = GroupMember | |
| 319 | 319 | _from_parent_attrs = {'group_id': 'id'} | |
@@ -331,7 +331,7 @@ class GroupNotificationSettingsManager(NotificationSettingsManager): | |||
| 331 | 331 | _from_parent_attrs = {'group_id': 'id'} | |
| 332 | 332 | ||
| 333 | 333 | ||
| 334 | - class GroupAccessRequest(AccessRequestMixin, RESTObject): | ||
| 334 | + class GroupAccessRequest(AccessRequestMixin, ObjectDeleteMixin, RESTObject): | ||
| 335 | 335 | pass | |
| 336 | 336 | ||
| 337 | 337 | ||
@@ -342,7 +342,7 @@ class GroupAccessRequestManager(GetFromListMixin, CreateMixin, DeleteMixin, | |||
| 342 | 342 | _from_parent_attrs = {'group_id': 'id'} | |
| 343 | 343 | ||
| 344 | 344 | ||
| 345 | - class Hook(RESTObject): | ||
| 345 | + class Hook(ObjectDeleteMixin, RESTObject): | ||
| 346 | 346 | _url = '/hooks' | |
| 347 | 347 | _short_print_attr = 'url' | |
| 348 | 348 | ||
@@ -378,7 +378,7 @@ class LicenseManager(RetrieveMixin, RESTManager): | |||
| 378 | 378 | _optional_get_attrs = ('project', 'fullname') | |
| 379 | 379 | ||
| 380 | 380 | ||
| 381 | - class Snippet(SaveMixin, RESTObject): | ||
| 381 | + class Snippet(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 382 | 382 | _constructor_types = {'author': 'User'} | |
| 383 | 383 | _short_print_attr = 'title' | |
| 384 | 384 | ||
@@ -433,7 +433,7 @@ class NamespaceManager(GetFromListMixin, RESTManager): | |||
| 433 | 433 | _list_filters = ('search', ) | |
| 434 | 434 | ||
| 435 | 435 | ||
| 436 | - class ProjectBoardList(SaveMixin, RESTObject): | ||
| 436 | + class ProjectBoardList(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 437 | 437 | _constructor_types = {'label': 'ProjectLabel'} | |
| 438 | 438 | ||
| 439 | 439 | ||
@@ -457,7 +457,7 @@ class ProjectBoardManager(GetFromListMixin, RESTManager): | |||
| 457 | 457 | _from_parent_attrs = {'project_id': 'id'} | |
| 458 | 458 | ||
| 459 | 459 | ||
| 460 | - class ProjectBranch(RESTObject): | ||
| 460 | + class ProjectBranch(ObjectDeleteMixin, RESTObject): | ||
| 461 | 461 | _constructor_types = {'author': 'User', "committer": "User"} | |
| 462 | 462 | _id_attr = 'name' | |
| 463 | 463 | ||
@@ -640,7 +640,7 @@ class ProjectCommitManager(RetrieveMixin, CreateMixin, RESTManager): | |||
| 640 | 640 | ('author_email', 'author_name')) | |
| 641 | 641 | ||
| 642 | 642 | ||
| 643 | - class ProjectEnvironment(SaveMixin, RESTObject): | ||
| 643 | + class ProjectEnvironment(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 644 | 644 | pass | |
| 645 | 645 | ||
| 646 | 646 | ||
@@ -653,7 +653,7 @@ class ProjectEnvironmentManager(GetFromListMixin, CreateMixin, UpdateMixin, | |||
| 653 | 653 | _update_attrs = (tuple(), ('name', 'external_url')) | |
| 654 | 654 | ||
| 655 | 655 | ||
| 656 | - class ProjectKey(RESTObject): | ||
| 656 | + class ProjectKey(ObjectDeleteMixin, RESTObject): | ||
| 657 | 657 | pass | |
| 658 | 658 | ||
| 659 | 659 | ||
@@ -694,7 +694,7 @@ class ProjectForkManager(CreateMixin, RESTManager): | |||
| 694 | 694 | _create_attrs = (tuple(), ('namespace', )) | |
| 695 | 695 | ||
| 696 | 696 | ||
| 697 | - class ProjectHook(SaveMixin, RESTObject): | ||
| 697 | + class ProjectHook(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 698 | 698 | requiredUrlAttrs = ['project_id'] | |
| 699 | 699 | requiredCreateAttrs = ['url'] | |
| 700 | 700 | optionalCreateAttrs = ['push_events', 'issues_events', 'note_events', | |
@@ -722,12 +722,11 @@ class ProjectHookManager(CRUDMixin, RESTManager): | |||
| 722 | 722 | ) | |
| 723 | 723 | ||
| 724 | 724 | ||
| 725 | - class ProjectIssueNote(SaveMixin, RESTObject): | ||
| 725 | + class ProjectIssueNote(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 726 | 726 | _constructor_types = {'author': 'User'} | |
| 727 | 727 | ||
| 728 | 728 | ||
| 729 | - class ProjectIssueNoteManager(RetrieveMixin, CreateMixin, UpdateMixin, | ||
| 730 | - RESTManager): | ||
| 729 | + class ProjectIssueNoteManager(CRUDMixin, RESTManager): | ||
| 731 | 730 | _path = '/projects/%(project_id)s/issues/%(issue_iid)s/notes' | |
| 732 | 731 | _obj_cls = ProjectIssueNote | |
| 733 | 732 | _from_parent_attrs = {'project_id': 'project_id', 'issue_iid': 'iid'} | |
@@ -736,7 +735,7 @@ class ProjectIssueNoteManager(RetrieveMixin, CreateMixin, UpdateMixin, | |||
| 736 | 735 | ||
| 737 | 736 | ||
| 738 | 737 | class ProjectIssue(SubscribableMixin, TodoMixin, TimeTrackingMixin, SaveMixin, | |
| 739 | - RESTObject): | ||
| 738 | + ObjectDeleteMixin, RESTObject): | ||
| 740 | 739 | _constructor_types = {'author': 'User', 'assignee': 'User', 'milestone': | |
| 741 | 740 | 'ProjectMilestone'} | |
| 742 | 741 | _short_print_attr = 'title' | |
@@ -765,7 +764,7 @@ class ProjectIssueManager(CRUDMixin, RESTManager): | |||
| 765 | 764 | 'updated_at', 'state_event', 'due_date')) | |
| 766 | 765 | ||
| 767 | 766 | ||
| 768 | - class ProjectMember(SaveMixin, RESTObject): | ||
| 767 | + class ProjectMember(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 769 | 768 | requiredCreateAttrs = ['access_level', 'user_id'] | |
| 770 | 769 | optionalCreateAttrs = ['expires_at'] | |
| 771 | 770 | requiredUpdateAttrs = ['access_level'] | |
@@ -802,7 +801,7 @@ class ProjectNotificationSettingsManager(NotificationSettingsManager): | |||
| 802 | 801 | _from_parent_attrs = {'project_id': 'id'} | |
| 803 | 802 | ||
| 804 | 803 | ||
| 805 | - class ProjectTag(RESTObject): | ||
| 804 | + class ProjectTag(ObjectDeleteMixin, RESTObject): | ||
| 806 | 805 | _constructor_types = {'release': 'ProjectTagRelease', | |
| 807 | 806 | 'commit': 'ProjectCommit'} | |
| 808 | 807 | _id_attr = 'name' | |
@@ -846,7 +845,7 @@ class ProjectMergeRequestDiffManager(RetrieveMixin, RESTManager): | |||
| 846 | 845 | _from_parent_attrs = {'project_id': 'project_id', 'mr_iid': 'iid'} | |
| 847 | 846 | ||
| 848 | 847 | ||
| 849 | - class ProjectMergeRequestNote(SaveMixin, RESTObject): | ||
| 848 | + class ProjectMergeRequestNote(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 850 | 849 | _constructor_types = {'author': 'User'} | |
| 851 | 850 | ||
| 852 | 851 | ||
@@ -859,7 +858,7 @@ class ProjectMergeRequestNoteManager(CRUDMixin, RESTManager): | |||
| 859 | 858 | ||
| 860 | 859 | ||
| 861 | 860 | class ProjectMergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, | |
| 862 | - SaveMixin, RESTObject): | ||
| 861 | + SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 863 | 862 | _constructor_types = {'author': 'User', 'assignee': 'User'} | |
| 864 | 863 | _id_attr = 'iid' | |
| 865 | 864 | ||
@@ -952,7 +951,7 @@ class ProjectMergeRequestManager(CRUDMixin, RESTManager): | |||
| 952 | 951 | _list_filters = ('iids', 'state', 'order_by', 'sort') | |
| 953 | 952 | ||
| 954 | 953 | ||
| 955 | - class ProjectMilestone(SaveMixin, RESTObject): | ||
| 954 | + class ProjectMilestone(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 956 | 955 | _short_print_attr = 'title' | |
| 957 | 956 | ||
| 958 | 957 | def issues(self, **kwargs): | |
@@ -995,7 +994,8 @@ class ProjectMilestoneManager(RetrieveMixin, CreateMixin, DeleteMixin, | |||
| 995 | 994 | _list_filters = ('iids', 'state') | |
| 996 | 995 | ||
| 997 | 996 | ||
| 998 | - class ProjectLabel(SubscribableMixin, SaveMixin, RESTObject): | ||
| 997 | + class ProjectLabel(SubscribableMixin, SaveMixin, ObjectDeleteMixin, | ||
| 998 | + RESTObject): | ||
| 999 | 999 | _id_attr = 'name' | |
| 1000 | 1000 | requiredCreateAttrs = ['name', 'color'] | |
| 1001 | 1001 | optionalCreateAttrs = ['description', 'priority'] | |
@@ -1004,7 +1004,7 @@ class ProjectLabel(SubscribableMixin, SaveMixin, RESTObject): | |||
| 1004 | 1004 | ||
| 1005 | 1005 | ||
| 1006 | 1006 | class ProjectLabelManager(GetFromListMixin, CreateMixin, UpdateMixin, | |
| 1007 | - RESTManager): | ||
| 1007 | + DeleteMixin, RESTManager): | ||
| 1008 | 1008 | _path = '/projects/%(project_id)s/labels' | |
| 1009 | 1009 | _obj_cls = ProjectLabel | |
| 1010 | 1010 | _from_parent_attrs = {'project_id': 'id'} | |
@@ -1038,7 +1038,7 @@ def save(self, **kwargs): | |||
| 1038 | 1038 | self._update_attrs(server_data) | |
| 1039 | 1039 | ||
| 1040 | 1040 | ||
| 1041 | - class ProjectFile(SaveMixin, RESTObject): | ||
| 1041 | + class ProjectFile(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 1042 | 1042 | _id_attr = 'file_path' | |
| 1043 | 1043 | _short_print_attr = 'file_path' | |
| 1044 | 1044 | ||
@@ -1145,7 +1145,7 @@ class ProjectSnippetNoteManager(RetrieveMixin, CreateMixin, RESTManager): | |||
| 1145 | 1145 | _create_attrs = (('body', ), tuple()) | |
| 1146 | 1146 | ||
| 1147 | 1147 | ||
| 1148 | - class ProjectSnippet(SaveMixin, RESTObject): | ||
| 1148 | + class ProjectSnippet(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 1149 | 1149 | _url = '/projects/%(project_id)s/snippets' | |
| 1150 | 1150 | _constructor_types = {'author': 'User'} | |
| 1151 | 1151 | _short_print_attr = 'title' | |
@@ -1180,7 +1180,7 @@ class ProjectSnippetManager(CRUDMixin, RESTManager): | |||
| 1180 | 1180 | _update_attrs = (tuple(), ('title', 'file_name', 'code', 'visibility')) | |
| 1181 | 1181 | ||
| 1182 | 1182 | ||
| 1183 | - class ProjectTrigger(SaveMixin, RESTObject): | ||
| 1183 | + class ProjectTrigger(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 1184 | 1184 | def take_ownership(self, **kwargs): | |
| 1185 | 1185 | """Update the owner of a trigger.""" | |
| 1186 | 1186 | path = '%s/%s/take_ownership' % (self.manager.path, self.get_id()) | |
@@ -1196,7 +1196,7 @@ class ProjectTriggerManager(CRUDMixin, RESTManager): | |||
| 1196 | 1196 | _update_attrs = (('description', ), tuple()) | |
| 1197 | 1197 | ||
| 1198 | 1198 | ||
| 1199 | - class ProjectVariable(SaveMixin, RESTObject): | ||
| 1199 | + class ProjectVariable(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 1200 | 1200 | _id_attr = 'key' | |
| 1201 | 1201 | ||
| 1202 | 1202 | ||
@@ -1297,7 +1297,7 @@ def available(self, **kwargs): | |||
| 1297 | 1297 | return list(ProjectService._service_attrs.keys()) | |
| 1298 | 1298 | ||
| 1299 | 1299 | ||
| 1300 | - class ProjectAccessRequest(AccessRequestMixin, RESTObject): | ||
| 1300 | + class ProjectAccessRequest(AccessRequestMixin, ObjectDeleteMixin, RESTObject): | ||
| 1301 | 1301 | pass | |
| 1302 | 1302 | ||
| 1303 | 1303 | ||
@@ -1318,7 +1318,7 @@ class ProjectDeploymentManager(RetrieveMixin, RESTManager): | |||
| 1318 | 1318 | _from_parent_attrs = {'project_id': 'id'} | |
| 1319 | 1319 | ||
| 1320 | 1320 | ||
| 1321 | - class ProjectRunner(RESTObject): | ||
| 1321 | + class ProjectRunner(ObjectDeleteMixin, RESTObject): | ||
| 1322 | 1322 | canUpdate = False | |
| 1323 | 1323 | requiredCreateAttrs = ['runner_id'] | |
| 1324 | 1324 | ||
@@ -1330,7 +1330,7 @@ class ProjectRunnerManager(NoUpdateMixin, RESTManager): | |||
| 1330 | 1330 | _create_attrs = (('runner_id', ), tuple()) | |
| 1331 | 1331 | ||
| 1332 | 1332 | ||
| 1333 | - class Project(SaveMixin, RESTObject): | ||
| 1333 | + class Project(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 1334 | 1334 | _constructor_types = {'owner': 'User', 'namespace': 'Group'} | |
| 1335 | 1335 | _short_print_attr = 'path' | |
| 1336 | 1336 | _managers = ( | |
@@ -1547,7 +1547,7 @@ def trigger_pipeline(self, ref, token, variables={}, **kwargs): | |||
| 1547 | 1547 | self.manager.gitlab.http_post(path, post_data=post_data, **kwargs) | |
| 1548 | 1548 | ||
| 1549 | 1549 | ||
| 1550 | - class Runner(SaveMixin, RESTObject): | ||
| 1550 | + class Runner(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 1551 | 1551 | pass | |
| 1552 | 1552 | ||
| 1553 | 1553 | ||
@@ -1574,7 +1574,7 @@ def all(self, scope=None, **kwargs): | |||
| 1574 | 1574 | return self.gitlab.http_list(path, query_data, **kwargs) | |
| 1575 | 1575 | ||
| 1576 | 1576 | ||
| 1577 | - class Todo(RESTObject): | ||
| 1577 | + class Todo(ObjectDeleteMixin, RESTObject): | ||
| 1578 | 1578 | def mark_as_done(self, **kwargs): | |
| 1579 | 1579 | """Mark the todo as done. | |
| 1580 | 1580 | ||
@@ -1640,7 +1640,7 @@ class GroupProjectManager(GetFromListMixin, RESTManager): | |||
| 1640 | 1640 | 'ci_enabled_first') | |
| 1641 | 1641 | ||
| 1642 | 1642 | ||
| 1643 | - class Group(SaveMixin, RESTObject): | ||
| 1643 | + class Group(SaveMixin, ObjectDeleteMixin, RESTObject): | ||
| 1644 | 1644 | _short_print_attr = 'name' | |
| 1645 | 1645 | _managers = ( | |
| 1646 | 1646 | ('accessrequests', 'GroupAccessRequestManager'), | |
| Back | FazBrowse Home | New Git URL |
0 commit comments