Loading gitlab/base.py +5 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ class RESTObject(object): without ID in the url. """ _id_attr = 'id' _path = None def __init__(self, manager, attrs): self.__dict__.update({ Loading Loading @@ -131,6 +132,10 @@ class RESTObject(object): return None return getattr(self, self._id_attr) def get_path(self): """Returns the path of the resource.""" return '%s/%s' % (self._path or self.manager.path, self.get_id()) @property def attributes(self): d = self.__dict__['_updated_attrs'].copy() Loading gitlab/mixins.py +30 −23 Original line number Diff line number Diff line Loading @@ -401,7 +401,7 @@ class UserAgentDetailMixin(object): GitlabAuthenticationError: If authentication is not correct GitlabGetError: If the server cannot perform the request """ path = '%s/%s/user_agent_detail' % (self.manager.path, self.get_id()) path = self.get_path() + '/user_agent_detail' return self.manager.gitlab.http_get(path, **kwargs) Loading @@ -420,8 +420,7 @@ class AccessRequestMixin(object): GitlabAuthenticationError: If authentication is not correct GitlabUpdateError: If the server fails to perform the request """ path = '%s/%s/approve' % (self.manager.path, self.id) path = self.get_path() + '/approve' data = {'access_level': access_level} server_data = self.manager.gitlab.http_put(path, post_data=data, **kwargs) Loading @@ -429,8 +428,9 @@ class AccessRequestMixin(object): class SubscribableMixin(object): @cli.register_custom_action(('ProjectIssue', 'ProjectMergeRequest', 'ProjectLabel')) @cli.register_custom_action(('ProjectIssue', 'ProjectLabel', 'MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabSubscribeError) def subscribe(self, **kwargs): """Subscribe to the object notifications. Loading @@ -442,12 +442,13 @@ class SubscribableMixin(object): GitlabAuthenticationError: If authentication is not correct GitlabSubscribeError: If the subscription cannot be done """ path = '%s/%s/subscribe' % (self.manager.path, self.get_id()) path = self.get_path() + '/subscribe' server_data = self.manager.gitlab.http_post(path, **kwargs) self._update_attrs(server_data) @cli.register_custom_action(('ProjectIssue', 'ProjectMergeRequest', 'ProjectLabel')) @cli.register_custom_action(('ProjectIssue', 'ProjectLabel', 'MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabUnsubscribeError) def unsubscribe(self, **kwargs): """Unsubscribe from the object notifications. Loading @@ -459,13 +460,14 @@ class SubscribableMixin(object): GitlabAuthenticationError: If authentication is not correct GitlabUnsubscribeError: If the unsubscription cannot be done """ path = '%s/%s/unsubscribe' % (self.manager.path, self.get_id()) path = self.get_path() + '/unsubscribe' server_data = self.manager.gitlab.http_post(path, **kwargs) self._update_attrs(server_data) class TodoMixin(object): @cli.register_custom_action(('ProjectIssue', 'ProjectMergeRequest')) @cli.register_custom_action(('ProjectIssue', 'MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabTodoError) def todo(self, **kwargs): """Create a todo associated to the object. Loading @@ -477,12 +479,13 @@ class TodoMixin(object): GitlabAuthenticationError: If authentication is not correct GitlabTodoError: If the todo cannot be set """ path = '%s/%s/todo' % (self.manager.path, self.get_id()) path = self.get_path() + '/todo' self.manager.gitlab.http_post(path, **kwargs) class TimeTrackingMixin(object): @cli.register_custom_action(('ProjectIssue', 'ProjectMergeRequest')) @cli.register_custom_action(('ProjectIssue', 'MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabTimeTrackingError) def time_stats(self, **kwargs): """Get time stats for the object. Loading @@ -499,10 +502,11 @@ class TimeTrackingMixin(object): if 'time_stats' in self.attributes: return self.attributes['time_stats'] path = '%s/%s/time_stats' % (self.manager.path, self.get_id()) path = self.get_path() + '/time_stats' return self.manager.gitlab.http_get(path, **kwargs) @cli.register_custom_action(('ProjectIssue', 'ProjectMergeRequest'), @cli.register_custom_action(('ProjectIssue', 'MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest'), ('duration', )) @exc.on_http_error(exc.GitlabTimeTrackingError) def time_estimate(self, duration, **kwargs): Loading @@ -516,11 +520,12 @@ class TimeTrackingMixin(object): GitlabAuthenticationError: If authentication is not correct GitlabTimeTrackingError: If the time tracking update cannot be done """ path = '%s/%s/time_estimate' % (self.manager.path, self.get_id()) path = self.get_path() + '/time_estimate' data = {'duration': duration} return self.manager.gitlab.http_post(path, post_data=data, **kwargs) @cli.register_custom_action(('ProjectIssue', 'ProjectMergeRequest')) @cli.register_custom_action(('ProjectIssue', 'MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabTimeTrackingError) def reset_time_estimate(self, **kwargs): """Resets estimated time for the object to 0 seconds. Loading @@ -535,7 +540,8 @@ class TimeTrackingMixin(object): path = '%s/%s/reset_time_estimate' % (self.manager.path, self.get_id()) return self.manager.gitlab.http_post(path, **kwargs) @cli.register_custom_action(('ProjectIssue', 'ProjectMergeRequest'), @cli.register_custom_action(('ProjectIssue', 'MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest'), ('duration', )) @exc.on_http_error(exc.GitlabTimeTrackingError) def add_spent_time(self, duration, **kwargs): Loading @@ -549,11 +555,12 @@ class TimeTrackingMixin(object): GitlabAuthenticationError: If authentication is not correct GitlabTimeTrackingError: If the time tracking update cannot be done """ path = '%s/%s/add_spent_time' % (self.manager.path, self.get_id()) path = self.get_path() + '/add_spent_time' data = {'duration': duration} return self.manager.gitlab.http_post(path, post_data=data, **kwargs) @cli.register_custom_action(('ProjectIssue', 'ProjectMergeRequest')) @cli.register_custom_action(('ProjectIssue', 'MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabTimeTrackingError) def reset_spent_time(self, **kwargs): """Resets the time spent working on the object. Loading @@ -565,12 +572,13 @@ class TimeTrackingMixin(object): GitlabAuthenticationError: If authentication is not correct GitlabTimeTrackingError: If the time tracking update cannot be done """ path = '%s/%s/reset_spent_time' % (self.manager.path, self.get_id()) path = self.get_path() + '/reset_spent_time' return self.manager.gitlab.http_post(path, **kwargs) class ParticipantsMixin(object): @cli.register_custom_action(('ProjectMergeRequest', 'ProjectIssue')) @cli.register_custom_action(('MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest', 'ProjectIssue')) @exc.on_http_error(exc.GitlabListError) def participants(self, **kwargs): """List the participants. Loading @@ -590,8 +598,7 @@ class ParticipantsMixin(object): Returns: RESTObjectList: The list of participants """ path = '%s/%s/participants' % (self.manager.path, self.get_id()) path = self.get_path() + '/participants' return self.manager.gitlab.http_get(path, **kwargs) Loading gitlab/v4/objects.py +34 −16 Original line number Diff line number Diff line Loading @@ -855,7 +855,8 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject): ('variables', 'GroupVariableManager'), ) @cli.register_custom_action('Group', ('to_project_id', )) @cli.register_custom_action(('Group', 'GroupSubgroup'), ('to_project_id', )) @exc.on_http_error(exc.GitlabTransferProjectError) def transfer_project(self, to_project_id, **kwargs): """Transfer a project to this group. Loading @@ -871,7 +872,8 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject): path = '/groups/%s/projects/%s' % (self.id, to_project_id) self.manager.gitlab.http_post(path, **kwargs) @cli.register_custom_action('Group', ('scope', 'search')) @cli.register_custom_action(('Group', 'GroupSubgroup'), ('scope', 'search')) @exc.on_http_error(exc.GitlabSearchError) def search(self, scope, search, **kwargs): """Search the group resources matching the provided string.' Loading @@ -892,7 +894,8 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject): path = '/groups/%s/search' % self.get_id() return self.manager.gitlab.http_list(path, query_data=data, **kwargs) @cli.register_custom_action('Group', ('cn', 'group_access', 'provider')) @cli.register_custom_action(('Group', 'GroupSubgroup'), ('cn', 'group_access', 'provider')) @exc.on_http_error(exc.GitlabCreateError) def add_ldap_group_link(self, cn, group_access, provider, **kwargs): """Add an LDAP group link. Loading @@ -912,7 +915,8 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject): data = {'cn': cn, 'group_access': group_access, 'provider': provider} self.manager.gitlab.http_post(path, post_data=data, **kwargs) @cli.register_custom_action('Group', ('cn',), ('provider',)) @cli.register_custom_action(('Group', 'GroupSubgroup'), ('cn',), ('provider',)) @exc.on_http_error(exc.GitlabDeleteError) def delete_ldap_group_link(self, cn, provider=None, **kwargs): """Delete an LDAP group link. Loading @@ -932,7 +936,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject): path += '/%s' % cn self.manager.gitlab.http_delete(path) @cli.register_custom_action('Group') @cli.register_custom_action(('Group', 'GroupSubgroup')) @exc.on_http_error(exc.GitlabCreateError) def ldap_sync(self, **kwargs): """Sync LDAP groups. Loading Loading @@ -1049,7 +1053,13 @@ class LicenseManager(RetrieveMixin, RESTManager): class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, ParticipantsMixin, SaveMixin, ObjectDeleteMixin, RESTObject): _id_attr = 'iid' _id_attr = 'iid' #TODO: should be tuple ('project_id','iid') _short_print_attr = 'title' _path = '/projects/%s/merge_requests' def get_path(self): print('Project_id: ', self.project_id) return '%s/%s' % (self.path % self.project_id, self.get_id()) _managers = ( ('approvals', 'ProjectMergeRequestApprovalManager'), Loading @@ -1061,7 +1071,8 @@ class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, 'ProjectMergeRequestResourceLabelEventManager'), ) @cli.register_custom_action('MergeRequest') @cli.register_custom_action(('MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabMROnBuildSuccessError) def cancel_merge_when_pipeline_succeeds(self, **kwargs): """Cancel merge when the pipeline succeeds. Loading @@ -1078,7 +1089,8 @@ class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, server_data = self.manager.gitlab.http_put(path, **kwargs) self._update_attrs(server_data) @cli.register_custom_action('MergeRequest') @cli.register_custom_action(('MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabListError) def closes_issues(self, **kwargs): """List issues that will close on merge." Loading @@ -1105,7 +1117,8 @@ class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, parent=self.manager._parent) return RESTObjectList(manager, ProjectIssue, data_list) @cli.register_custom_action('MergeRequest') @cli.register_custom_action(('MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabListError) def commits(self, **kwargs): """List the merge request commits. Loading @@ -1132,7 +1145,8 @@ class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, parent=self.manager._parent) return RESTObjectList(manager, ProjectCommit, data_list) @cli.register_custom_action('MergeRequest') @cli.register_custom_action(('MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabListError) def changes(self, **kwargs): """List the merge request changes. Loading @@ -1150,7 +1164,8 @@ class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, path = self._get_path() + '/changes' return self.manager.gitlab.http_get(path, **kwargs) @cli.register_custom_action('MergeRequest') @cli.register_custom_action(('MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabListError) def pipelines(self, **kwargs): """List the merge request pipelines. Loading @@ -1168,7 +1183,8 @@ class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, path = self._get_path() + '/pipelines' return self.manager.gitlab.http_get(path, **kwargs) @cli.register_custom_action('MergeRequest', tuple(), ('sha')) @cli.register_custom_action(('MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest'), tuple(), ('sha')) @exc.on_http_error(exc.GitlabMRApprovalError) def approve(self, sha=None, **kwargs): """Approve the merge request. Loading @@ -1190,7 +1206,8 @@ class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, **kwargs) self._update_attrs(server_data) @cli.register_custom_action('MergeRequest') @cli.register_custom_action(('MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabMRApprovalError) def unapprove(self, **kwargs): """Unapprove the merge request. Loading @@ -1209,7 +1226,9 @@ class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, **kwargs) self._update_attrs(server_data) @cli.register_custom_action('MergeRequest', tuple(), @cli.register_custom_action(('MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest'), tuple(), ('merge_commit_message', 'should_remove_source_branch', 'merge_when_pipeline_succeeds')) Loading Loading @@ -1245,7 +1264,7 @@ class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, **kwargs) self._update_attrs(server_data) def _get_path(): def _get_path(self): if not hasattr(self, '_path'): self._path = ('/projects/%s/merge_requests/%s' % (self.project_id, self.get_id())) Loading @@ -1255,7 +1274,6 @@ class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, class MergeRequestManager(ListMixin, RESTManager): _path = '/merge_requests' _obj_cls = MergeRequest _from_parent_attrs = {'group_id': 'id'} _list_filters = ('state', 'order_by', 'sort', 'milestone', 'view', 'labels', 'created_after', 'created_before', 'updated_after', 'updated_before', 'scope', 'author_id', Loading Loading
gitlab/base.py +5 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ class RESTObject(object): without ID in the url. """ _id_attr = 'id' _path = None def __init__(self, manager, attrs): self.__dict__.update({ Loading Loading @@ -131,6 +132,10 @@ class RESTObject(object): return None return getattr(self, self._id_attr) def get_path(self): """Returns the path of the resource.""" return '%s/%s' % (self._path or self.manager.path, self.get_id()) @property def attributes(self): d = self.__dict__['_updated_attrs'].copy() Loading
gitlab/mixins.py +30 −23 Original line number Diff line number Diff line Loading @@ -401,7 +401,7 @@ class UserAgentDetailMixin(object): GitlabAuthenticationError: If authentication is not correct GitlabGetError: If the server cannot perform the request """ path = '%s/%s/user_agent_detail' % (self.manager.path, self.get_id()) path = self.get_path() + '/user_agent_detail' return self.manager.gitlab.http_get(path, **kwargs) Loading @@ -420,8 +420,7 @@ class AccessRequestMixin(object): GitlabAuthenticationError: If authentication is not correct GitlabUpdateError: If the server fails to perform the request """ path = '%s/%s/approve' % (self.manager.path, self.id) path = self.get_path() + '/approve' data = {'access_level': access_level} server_data = self.manager.gitlab.http_put(path, post_data=data, **kwargs) Loading @@ -429,8 +428,9 @@ class AccessRequestMixin(object): class SubscribableMixin(object): @cli.register_custom_action(('ProjectIssue', 'ProjectMergeRequest', 'ProjectLabel')) @cli.register_custom_action(('ProjectIssue', 'ProjectLabel', 'MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabSubscribeError) def subscribe(self, **kwargs): """Subscribe to the object notifications. Loading @@ -442,12 +442,13 @@ class SubscribableMixin(object): GitlabAuthenticationError: If authentication is not correct GitlabSubscribeError: If the subscription cannot be done """ path = '%s/%s/subscribe' % (self.manager.path, self.get_id()) path = self.get_path() + '/subscribe' server_data = self.manager.gitlab.http_post(path, **kwargs) self._update_attrs(server_data) @cli.register_custom_action(('ProjectIssue', 'ProjectMergeRequest', 'ProjectLabel')) @cli.register_custom_action(('ProjectIssue', 'ProjectLabel', 'MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabUnsubscribeError) def unsubscribe(self, **kwargs): """Unsubscribe from the object notifications. Loading @@ -459,13 +460,14 @@ class SubscribableMixin(object): GitlabAuthenticationError: If authentication is not correct GitlabUnsubscribeError: If the unsubscription cannot be done """ path = '%s/%s/unsubscribe' % (self.manager.path, self.get_id()) path = self.get_path() + '/unsubscribe' server_data = self.manager.gitlab.http_post(path, **kwargs) self._update_attrs(server_data) class TodoMixin(object): @cli.register_custom_action(('ProjectIssue', 'ProjectMergeRequest')) @cli.register_custom_action(('ProjectIssue', 'MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabTodoError) def todo(self, **kwargs): """Create a todo associated to the object. Loading @@ -477,12 +479,13 @@ class TodoMixin(object): GitlabAuthenticationError: If authentication is not correct GitlabTodoError: If the todo cannot be set """ path = '%s/%s/todo' % (self.manager.path, self.get_id()) path = self.get_path() + '/todo' self.manager.gitlab.http_post(path, **kwargs) class TimeTrackingMixin(object): @cli.register_custom_action(('ProjectIssue', 'ProjectMergeRequest')) @cli.register_custom_action(('ProjectIssue', 'MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabTimeTrackingError) def time_stats(self, **kwargs): """Get time stats for the object. Loading @@ -499,10 +502,11 @@ class TimeTrackingMixin(object): if 'time_stats' in self.attributes: return self.attributes['time_stats'] path = '%s/%s/time_stats' % (self.manager.path, self.get_id()) path = self.get_path() + '/time_stats' return self.manager.gitlab.http_get(path, **kwargs) @cli.register_custom_action(('ProjectIssue', 'ProjectMergeRequest'), @cli.register_custom_action(('ProjectIssue', 'MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest'), ('duration', )) @exc.on_http_error(exc.GitlabTimeTrackingError) def time_estimate(self, duration, **kwargs): Loading @@ -516,11 +520,12 @@ class TimeTrackingMixin(object): GitlabAuthenticationError: If authentication is not correct GitlabTimeTrackingError: If the time tracking update cannot be done """ path = '%s/%s/time_estimate' % (self.manager.path, self.get_id()) path = self.get_path() + '/time_estimate' data = {'duration': duration} return self.manager.gitlab.http_post(path, post_data=data, **kwargs) @cli.register_custom_action(('ProjectIssue', 'ProjectMergeRequest')) @cli.register_custom_action(('ProjectIssue', 'MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabTimeTrackingError) def reset_time_estimate(self, **kwargs): """Resets estimated time for the object to 0 seconds. Loading @@ -535,7 +540,8 @@ class TimeTrackingMixin(object): path = '%s/%s/reset_time_estimate' % (self.manager.path, self.get_id()) return self.manager.gitlab.http_post(path, **kwargs) @cli.register_custom_action(('ProjectIssue', 'ProjectMergeRequest'), @cli.register_custom_action(('ProjectIssue', 'MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest'), ('duration', )) @exc.on_http_error(exc.GitlabTimeTrackingError) def add_spent_time(self, duration, **kwargs): Loading @@ -549,11 +555,12 @@ class TimeTrackingMixin(object): GitlabAuthenticationError: If authentication is not correct GitlabTimeTrackingError: If the time tracking update cannot be done """ path = '%s/%s/add_spent_time' % (self.manager.path, self.get_id()) path = self.get_path() + '/add_spent_time' data = {'duration': duration} return self.manager.gitlab.http_post(path, post_data=data, **kwargs) @cli.register_custom_action(('ProjectIssue', 'ProjectMergeRequest')) @cli.register_custom_action(('ProjectIssue', 'MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabTimeTrackingError) def reset_spent_time(self, **kwargs): """Resets the time spent working on the object. Loading @@ -565,12 +572,13 @@ class TimeTrackingMixin(object): GitlabAuthenticationError: If authentication is not correct GitlabTimeTrackingError: If the time tracking update cannot be done """ path = '%s/%s/reset_spent_time' % (self.manager.path, self.get_id()) path = self.get_path() + '/reset_spent_time' return self.manager.gitlab.http_post(path, **kwargs) class ParticipantsMixin(object): @cli.register_custom_action(('ProjectMergeRequest', 'ProjectIssue')) @cli.register_custom_action(('MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest', 'ProjectIssue')) @exc.on_http_error(exc.GitlabListError) def participants(self, **kwargs): """List the participants. Loading @@ -590,8 +598,7 @@ class ParticipantsMixin(object): Returns: RESTObjectList: The list of participants """ path = '%s/%s/participants' % (self.manager.path, self.get_id()) path = self.get_path() + '/participants' return self.manager.gitlab.http_get(path, **kwargs) Loading
gitlab/v4/objects.py +34 −16 Original line number Diff line number Diff line Loading @@ -855,7 +855,8 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject): ('variables', 'GroupVariableManager'), ) @cli.register_custom_action('Group', ('to_project_id', )) @cli.register_custom_action(('Group', 'GroupSubgroup'), ('to_project_id', )) @exc.on_http_error(exc.GitlabTransferProjectError) def transfer_project(self, to_project_id, **kwargs): """Transfer a project to this group. Loading @@ -871,7 +872,8 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject): path = '/groups/%s/projects/%s' % (self.id, to_project_id) self.manager.gitlab.http_post(path, **kwargs) @cli.register_custom_action('Group', ('scope', 'search')) @cli.register_custom_action(('Group', 'GroupSubgroup'), ('scope', 'search')) @exc.on_http_error(exc.GitlabSearchError) def search(self, scope, search, **kwargs): """Search the group resources matching the provided string.' Loading @@ -892,7 +894,8 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject): path = '/groups/%s/search' % self.get_id() return self.manager.gitlab.http_list(path, query_data=data, **kwargs) @cli.register_custom_action('Group', ('cn', 'group_access', 'provider')) @cli.register_custom_action(('Group', 'GroupSubgroup'), ('cn', 'group_access', 'provider')) @exc.on_http_error(exc.GitlabCreateError) def add_ldap_group_link(self, cn, group_access, provider, **kwargs): """Add an LDAP group link. Loading @@ -912,7 +915,8 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject): data = {'cn': cn, 'group_access': group_access, 'provider': provider} self.manager.gitlab.http_post(path, post_data=data, **kwargs) @cli.register_custom_action('Group', ('cn',), ('provider',)) @cli.register_custom_action(('Group', 'GroupSubgroup'), ('cn',), ('provider',)) @exc.on_http_error(exc.GitlabDeleteError) def delete_ldap_group_link(self, cn, provider=None, **kwargs): """Delete an LDAP group link. Loading @@ -932,7 +936,7 @@ class Group(SaveMixin, ObjectDeleteMixin, RESTObject): path += '/%s' % cn self.manager.gitlab.http_delete(path) @cli.register_custom_action('Group') @cli.register_custom_action(('Group', 'GroupSubgroup')) @exc.on_http_error(exc.GitlabCreateError) def ldap_sync(self, **kwargs): """Sync LDAP groups. Loading Loading @@ -1049,7 +1053,13 @@ class LicenseManager(RetrieveMixin, RESTManager): class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, ParticipantsMixin, SaveMixin, ObjectDeleteMixin, RESTObject): _id_attr = 'iid' _id_attr = 'iid' #TODO: should be tuple ('project_id','iid') _short_print_attr = 'title' _path = '/projects/%s/merge_requests' def get_path(self): print('Project_id: ', self.project_id) return '%s/%s' % (self.path % self.project_id, self.get_id()) _managers = ( ('approvals', 'ProjectMergeRequestApprovalManager'), Loading @@ -1061,7 +1071,8 @@ class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, 'ProjectMergeRequestResourceLabelEventManager'), ) @cli.register_custom_action('MergeRequest') @cli.register_custom_action(('MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabMROnBuildSuccessError) def cancel_merge_when_pipeline_succeeds(self, **kwargs): """Cancel merge when the pipeline succeeds. Loading @@ -1078,7 +1089,8 @@ class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, server_data = self.manager.gitlab.http_put(path, **kwargs) self._update_attrs(server_data) @cli.register_custom_action('MergeRequest') @cli.register_custom_action(('MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabListError) def closes_issues(self, **kwargs): """List issues that will close on merge." Loading @@ -1105,7 +1117,8 @@ class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, parent=self.manager._parent) return RESTObjectList(manager, ProjectIssue, data_list) @cli.register_custom_action('MergeRequest') @cli.register_custom_action(('MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabListError) def commits(self, **kwargs): """List the merge request commits. Loading @@ -1132,7 +1145,8 @@ class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, parent=self.manager._parent) return RESTObjectList(manager, ProjectCommit, data_list) @cli.register_custom_action('MergeRequest') @cli.register_custom_action(('MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabListError) def changes(self, **kwargs): """List the merge request changes. Loading @@ -1150,7 +1164,8 @@ class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, path = self._get_path() + '/changes' return self.manager.gitlab.http_get(path, **kwargs) @cli.register_custom_action('MergeRequest') @cli.register_custom_action(('MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabListError) def pipelines(self, **kwargs): """List the merge request pipelines. Loading @@ -1168,7 +1183,8 @@ class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, path = self._get_path() + '/pipelines' return self.manager.gitlab.http_get(path, **kwargs) @cli.register_custom_action('MergeRequest', tuple(), ('sha')) @cli.register_custom_action(('MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest'), tuple(), ('sha')) @exc.on_http_error(exc.GitlabMRApprovalError) def approve(self, sha=None, **kwargs): """Approve the merge request. Loading @@ -1190,7 +1206,8 @@ class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, **kwargs) self._update_attrs(server_data) @cli.register_custom_action('MergeRequest') @cli.register_custom_action(('MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest')) @exc.on_http_error(exc.GitlabMRApprovalError) def unapprove(self, **kwargs): """Unapprove the merge request. Loading @@ -1209,7 +1226,9 @@ class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, **kwargs) self._update_attrs(server_data) @cli.register_custom_action('MergeRequest', tuple(), @cli.register_custom_action(('MergeRequest', 'GroupMergeRequest', 'ProjectMergeRequest'), tuple(), ('merge_commit_message', 'should_remove_source_branch', 'merge_when_pipeline_succeeds')) Loading Loading @@ -1245,7 +1264,7 @@ class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, **kwargs) self._update_attrs(server_data) def _get_path(): def _get_path(self): if not hasattr(self, '_path'): self._path = ('/projects/%s/merge_requests/%s' % (self.project_id, self.get_id())) Loading @@ -1255,7 +1274,6 @@ class MergeRequest(SubscribableMixin, TodoMixin, TimeTrackingMixin, class MergeRequestManager(ListMixin, RESTManager): _path = '/merge_requests' _obj_cls = MergeRequest _from_parent_attrs = {'group_id': 'id'} _list_filters = ('state', 'order_by', 'sort', 'milestone', 'view', 'labels', 'created_after', 'created_before', 'updated_after', 'updated_before', 'scope', 'author_id', Loading