Loading gitlab/cli.py +3 −2 Original line number Diff line number Diff line Loading @@ -72,8 +72,9 @@ class VerticalHelpFormatter(argparse.HelpFormatter): def register_custom_action( *, cls_names: Union[str, Tuple[str, ...]], mandatory: Tuple[str, ...] = (), required: Tuple[str, ...] = (), optional: Tuple[str, ...] = (), custom_action: Optional[str] = None, ) -> Callable[[__F], __F]: Loading @@ -98,7 +99,7 @@ def register_custom_action( custom_actions[final_name] = {} action = custom_action or f.__name__.replace("_", "-") custom_actions[final_name][action] = (mandatory, optional, in_obj) custom_actions[final_name][action] = (required, optional, in_obj) return cast(__F, wrapped_f) Loading gitlab/mixins.py +22 −14 Original line number Diff line number Diff line Loading @@ -550,7 +550,7 @@ class UserAgentDetailMixin(_RestObjectBase): _updated_attrs: Dict[str, Any] manager: base.RESTManager @cli.register_custom_action(("Snippet", "ProjectSnippet", "ProjectIssue")) @cli.register_custom_action(cls_names=("Snippet", "ProjectSnippet", "ProjectIssue")) @exc.on_http_error(exc.GitlabGetError) def user_agent_detail(self, **kwargs: Any) -> Dict[str, Any]: """Get the user agent detail. Loading Loading @@ -578,7 +578,8 @@ class AccessRequestMixin(_RestObjectBase): manager: base.RESTManager @cli.register_custom_action( ("ProjectAccessRequest", "GroupAccessRequest"), (), ("access_level",) cls_names=("ProjectAccessRequest", "GroupAccessRequest"), optional=("access_level",), ) @exc.on_http_error(exc.GitlabUpdateError) def approve( Loading Loading @@ -611,7 +612,7 @@ class DownloadMixin(_RestObjectBase): _updated_attrs: Dict[str, Any] manager: base.RESTManager @cli.register_custom_action(("GroupExport", "ProjectExport")) @cli.register_custom_action(cls_names=("GroupExport", "ProjectExport")) @exc.on_http_error(exc.GitlabGetError) def download( self, Loading Loading @@ -721,7 +722,7 @@ class SubscribableMixin(_RestObjectBase): manager: base.RESTManager @cli.register_custom_action( ("ProjectIssue", "ProjectMergeRequest", "ProjectLabel", "GroupLabel") cls_names=("ProjectIssue", "ProjectMergeRequest", "ProjectLabel", "GroupLabel") ) @exc.on_http_error(exc.GitlabSubscribeError) def subscribe(self, **kwargs: Any) -> None: Loading @@ -741,7 +742,7 @@ class SubscribableMixin(_RestObjectBase): self._update_attrs(server_data) @cli.register_custom_action( ("ProjectIssue", "ProjectMergeRequest", "ProjectLabel", "GroupLabel") cls_names=("ProjectIssue", "ProjectMergeRequest", "ProjectLabel", "GroupLabel") ) @exc.on_http_error(exc.GitlabUnsubscribeError) def unsubscribe(self, **kwargs: Any) -> None: Loading Loading @@ -769,7 +770,7 @@ class TodoMixin(_RestObjectBase): _updated_attrs: Dict[str, Any] manager: base.RESTManager @cli.register_custom_action(("ProjectIssue", "ProjectMergeRequest")) @cli.register_custom_action(cls_names=("ProjectIssue", "ProjectMergeRequest")) @exc.on_http_error(exc.GitlabTodoError) def todo(self, **kwargs: Any) -> None: """Create a todo associated to the object. Loading @@ -793,7 +794,7 @@ class TimeTrackingMixin(_RestObjectBase): _updated_attrs: Dict[str, Any] manager: base.RESTManager @cli.register_custom_action(("ProjectIssue", "ProjectMergeRequest")) @cli.register_custom_action(cls_names=("ProjectIssue", "ProjectMergeRequest")) @exc.on_http_error(exc.GitlabTimeTrackingError) def time_stats(self, **kwargs: Any) -> Dict[str, Any]: """Get time stats for the object. Loading @@ -819,7 +820,9 @@ class TimeTrackingMixin(_RestObjectBase): assert not isinstance(result, requests.Response) return result @cli.register_custom_action(("ProjectIssue", "ProjectMergeRequest"), ("duration",)) @cli.register_custom_action( cls_names=("ProjectIssue", "ProjectMergeRequest"), required=("duration",) ) @exc.on_http_error(exc.GitlabTimeTrackingError) def time_estimate(self, duration: str, **kwargs: Any) -> Dict[str, Any]: """Set an estimated time of work for the object. Loading @@ -839,7 +842,7 @@ class TimeTrackingMixin(_RestObjectBase): assert not isinstance(result, requests.Response) return result @cli.register_custom_action(("ProjectIssue", "ProjectMergeRequest")) @cli.register_custom_action(cls_names=("ProjectIssue", "ProjectMergeRequest")) @exc.on_http_error(exc.GitlabTimeTrackingError) def reset_time_estimate(self, **kwargs: Any) -> Dict[str, Any]: """Resets estimated time for the object to 0 seconds. Loading @@ -857,7 +860,9 @@ class TimeTrackingMixin(_RestObjectBase): assert not isinstance(result, requests.Response) return result @cli.register_custom_action(("ProjectIssue", "ProjectMergeRequest"), ("duration",)) @cli.register_custom_action( cls_names=("ProjectIssue", "ProjectMergeRequest"), required=("duration",) ) @exc.on_http_error(exc.GitlabTimeTrackingError) def add_spent_time(self, duration: str, **kwargs: Any) -> Dict[str, Any]: """Add time spent working on the object. Loading @@ -877,7 +882,7 @@ class TimeTrackingMixin(_RestObjectBase): assert not isinstance(result, requests.Response) return result @cli.register_custom_action(("ProjectIssue", "ProjectMergeRequest")) @cli.register_custom_action(cls_names=("ProjectIssue", "ProjectMergeRequest")) @exc.on_http_error(exc.GitlabTimeTrackingError) def reset_spent_time(self, **kwargs: Any) -> Dict[str, Any]: """Resets the time spent working on the object. Loading @@ -904,7 +909,7 @@ class ParticipantsMixin(_RestObjectBase): _updated_attrs: Dict[str, Any] manager: base.RESTManager @cli.register_custom_action(("ProjectMergeRequest", "ProjectIssue")) @cli.register_custom_action(cls_names=("ProjectMergeRequest", "ProjectIssue")) @exc.on_http_error(exc.GitlabListError) def participants(self, **kwargs: Any) -> Dict[str, Any]: """List the participants. Loading Loading @@ -932,7 +937,8 @@ class ParticipantsMixin(_RestObjectBase): class BadgeRenderMixin(_RestManagerBase): @cli.register_custom_action( ("GroupBadgeManager", "ProjectBadgeManager"), ("link_url", "image_url") cls_names=("GroupBadgeManager", "ProjectBadgeManager"), required=("link_url", "image_url"), ) @exc.on_http_error(exc.GitlabRenderError) def render(self, link_url: str, image_url: str, **kwargs: Any) -> Dict[str, Any]: Loading Loading @@ -1025,7 +1031,9 @@ class UploadMixin(_RestObjectBase): data = self.attributes return self._upload_path.format(**data) @cli.register_custom_action(("Project", "ProjectWiki"), ("filename", "filepath")) @cli.register_custom_action( cls_names=("Project", "ProjectWiki"), required=("filename", "filepath") ) @exc.on_http_error(exc.GitlabUploadError) def upload( self, Loading gitlab/v4/objects/artifacts.py +5 −2 Original line number Diff line number Diff line Loading @@ -44,7 +44,9 @@ class ProjectArtifactManager(RESTManager): self.gitlab.http_delete(path, **kwargs) @cli.register_custom_action( "ProjectArtifactManager", ("ref_name", "job"), ("job_token",) cls_names="ProjectArtifactManager", required=("ref_name", "job"), optional=("job_token",), ) @exc.on_http_error(exc.GitlabGetError) def download( Loading Loading @@ -93,7 +95,8 @@ class ProjectArtifactManager(RESTManager): ) @cli.register_custom_action( "ProjectArtifactManager", ("ref_name", "artifact_path", "job") cls_names="ProjectArtifactManager", required=("ref_name", "artifact_path", "job"), ) @exc.on_http_error(exc.GitlabGetError) def raw( Loading gitlab/v4/objects/ci_lint.py +4 −4 Original line number Diff line number Diff line Loading @@ -31,8 +31,8 @@ class CiLintManager(CreateMixin, RESTManager): ) @register_custom_action( "CiLintManager", ("content",), cls_names="CiLintManager", required=("content",), optional=("include_merged_yaml", "include_jobs"), ) def validate(self, *args: Any, **kwargs: Any) -> None: Loading Loading @@ -63,8 +63,8 @@ class ProjectCiLintManager(GetWithoutIdMixin, CreateMixin, RESTManager): return cast(ProjectCiLint, super().get(**kwargs)) @register_custom_action( "ProjectCiLintManager", ("content",), cls_names="ProjectCiLintManager", required=("content",), optional=("dry_run", "include_jobs", "ref"), ) def validate(self, *args: Any, **kwargs: Any) -> None: Loading gitlab/v4/objects/commits.py +6 −6 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ class ProjectCommit(RESTObject): discussions: ProjectCommitDiscussionManager statuses: "ProjectCommitStatusManager" @cli.register_custom_action("ProjectCommit") @cli.register_custom_action(cls_names="ProjectCommit") @exc.on_http_error(exc.GitlabGetError) def diff(self, **kwargs: Any) -> Union[gitlab.GitlabList, List[Dict[str, Any]]]: """Generate the commit diff. Loading @@ -46,7 +46,7 @@ class ProjectCommit(RESTObject): path = f"{self.manager.path}/{self.encoded_id}/diff" return self.manager.gitlab.http_list(path, **kwargs) @cli.register_custom_action("ProjectCommit", ("branch",)) @cli.register_custom_action(cls_names="ProjectCommit", required=("branch",)) @exc.on_http_error(exc.GitlabCherryPickError) def cherry_pick(self, branch: str, **kwargs: Any) -> None: """Cherry-pick a commit into a branch. Loading @@ -63,7 +63,7 @@ class ProjectCommit(RESTObject): post_data = {"branch": branch} self.manager.gitlab.http_post(path, post_data=post_data, **kwargs) @cli.register_custom_action("ProjectCommit", optional=("type",)) @cli.register_custom_action(cls_names="ProjectCommit", optional=("type",)) @exc.on_http_error(exc.GitlabGetError) def refs( self, type: str = "all", **kwargs: Any Loading @@ -85,7 +85,7 @@ class ProjectCommit(RESTObject): query_data = {"type": type} return self.manager.gitlab.http_list(path, query_data=query_data, **kwargs) @cli.register_custom_action("ProjectCommit") @cli.register_custom_action(cls_names="ProjectCommit") @exc.on_http_error(exc.GitlabGetError) def merge_requests( self, **kwargs: Any Loading @@ -105,7 +105,7 @@ class ProjectCommit(RESTObject): path = f"{self.manager.path}/{self.encoded_id}/merge_requests" return self.manager.gitlab.http_list(path, **kwargs) @cli.register_custom_action("ProjectCommit", ("branch",)) @cli.register_custom_action(cls_names="ProjectCommit", required=("branch",)) @exc.on_http_error(exc.GitlabRevertError) def revert( self, branch: str, **kwargs: Any Loading @@ -127,7 +127,7 @@ class ProjectCommit(RESTObject): post_data = {"branch": branch} return self.manager.gitlab.http_post(path, post_data=post_data, **kwargs) @cli.register_custom_action("ProjectCommit") @cli.register_custom_action(cls_names="ProjectCommit") @exc.on_http_error(exc.GitlabGetError) def signature(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]: """Get the signature of the commit. Loading Loading
gitlab/cli.py +3 −2 Original line number Diff line number Diff line Loading @@ -72,8 +72,9 @@ class VerticalHelpFormatter(argparse.HelpFormatter): def register_custom_action( *, cls_names: Union[str, Tuple[str, ...]], mandatory: Tuple[str, ...] = (), required: Tuple[str, ...] = (), optional: Tuple[str, ...] = (), custom_action: Optional[str] = None, ) -> Callable[[__F], __F]: Loading @@ -98,7 +99,7 @@ def register_custom_action( custom_actions[final_name] = {} action = custom_action or f.__name__.replace("_", "-") custom_actions[final_name][action] = (mandatory, optional, in_obj) custom_actions[final_name][action] = (required, optional, in_obj) return cast(__F, wrapped_f) Loading
gitlab/mixins.py +22 −14 Original line number Diff line number Diff line Loading @@ -550,7 +550,7 @@ class UserAgentDetailMixin(_RestObjectBase): _updated_attrs: Dict[str, Any] manager: base.RESTManager @cli.register_custom_action(("Snippet", "ProjectSnippet", "ProjectIssue")) @cli.register_custom_action(cls_names=("Snippet", "ProjectSnippet", "ProjectIssue")) @exc.on_http_error(exc.GitlabGetError) def user_agent_detail(self, **kwargs: Any) -> Dict[str, Any]: """Get the user agent detail. Loading Loading @@ -578,7 +578,8 @@ class AccessRequestMixin(_RestObjectBase): manager: base.RESTManager @cli.register_custom_action( ("ProjectAccessRequest", "GroupAccessRequest"), (), ("access_level",) cls_names=("ProjectAccessRequest", "GroupAccessRequest"), optional=("access_level",), ) @exc.on_http_error(exc.GitlabUpdateError) def approve( Loading Loading @@ -611,7 +612,7 @@ class DownloadMixin(_RestObjectBase): _updated_attrs: Dict[str, Any] manager: base.RESTManager @cli.register_custom_action(("GroupExport", "ProjectExport")) @cli.register_custom_action(cls_names=("GroupExport", "ProjectExport")) @exc.on_http_error(exc.GitlabGetError) def download( self, Loading Loading @@ -721,7 +722,7 @@ class SubscribableMixin(_RestObjectBase): manager: base.RESTManager @cli.register_custom_action( ("ProjectIssue", "ProjectMergeRequest", "ProjectLabel", "GroupLabel") cls_names=("ProjectIssue", "ProjectMergeRequest", "ProjectLabel", "GroupLabel") ) @exc.on_http_error(exc.GitlabSubscribeError) def subscribe(self, **kwargs: Any) -> None: Loading @@ -741,7 +742,7 @@ class SubscribableMixin(_RestObjectBase): self._update_attrs(server_data) @cli.register_custom_action( ("ProjectIssue", "ProjectMergeRequest", "ProjectLabel", "GroupLabel") cls_names=("ProjectIssue", "ProjectMergeRequest", "ProjectLabel", "GroupLabel") ) @exc.on_http_error(exc.GitlabUnsubscribeError) def unsubscribe(self, **kwargs: Any) -> None: Loading Loading @@ -769,7 +770,7 @@ class TodoMixin(_RestObjectBase): _updated_attrs: Dict[str, Any] manager: base.RESTManager @cli.register_custom_action(("ProjectIssue", "ProjectMergeRequest")) @cli.register_custom_action(cls_names=("ProjectIssue", "ProjectMergeRequest")) @exc.on_http_error(exc.GitlabTodoError) def todo(self, **kwargs: Any) -> None: """Create a todo associated to the object. Loading @@ -793,7 +794,7 @@ class TimeTrackingMixin(_RestObjectBase): _updated_attrs: Dict[str, Any] manager: base.RESTManager @cli.register_custom_action(("ProjectIssue", "ProjectMergeRequest")) @cli.register_custom_action(cls_names=("ProjectIssue", "ProjectMergeRequest")) @exc.on_http_error(exc.GitlabTimeTrackingError) def time_stats(self, **kwargs: Any) -> Dict[str, Any]: """Get time stats for the object. Loading @@ -819,7 +820,9 @@ class TimeTrackingMixin(_RestObjectBase): assert not isinstance(result, requests.Response) return result @cli.register_custom_action(("ProjectIssue", "ProjectMergeRequest"), ("duration",)) @cli.register_custom_action( cls_names=("ProjectIssue", "ProjectMergeRequest"), required=("duration",) ) @exc.on_http_error(exc.GitlabTimeTrackingError) def time_estimate(self, duration: str, **kwargs: Any) -> Dict[str, Any]: """Set an estimated time of work for the object. Loading @@ -839,7 +842,7 @@ class TimeTrackingMixin(_RestObjectBase): assert not isinstance(result, requests.Response) return result @cli.register_custom_action(("ProjectIssue", "ProjectMergeRequest")) @cli.register_custom_action(cls_names=("ProjectIssue", "ProjectMergeRequest")) @exc.on_http_error(exc.GitlabTimeTrackingError) def reset_time_estimate(self, **kwargs: Any) -> Dict[str, Any]: """Resets estimated time for the object to 0 seconds. Loading @@ -857,7 +860,9 @@ class TimeTrackingMixin(_RestObjectBase): assert not isinstance(result, requests.Response) return result @cli.register_custom_action(("ProjectIssue", "ProjectMergeRequest"), ("duration",)) @cli.register_custom_action( cls_names=("ProjectIssue", "ProjectMergeRequest"), required=("duration",) ) @exc.on_http_error(exc.GitlabTimeTrackingError) def add_spent_time(self, duration: str, **kwargs: Any) -> Dict[str, Any]: """Add time spent working on the object. Loading @@ -877,7 +882,7 @@ class TimeTrackingMixin(_RestObjectBase): assert not isinstance(result, requests.Response) return result @cli.register_custom_action(("ProjectIssue", "ProjectMergeRequest")) @cli.register_custom_action(cls_names=("ProjectIssue", "ProjectMergeRequest")) @exc.on_http_error(exc.GitlabTimeTrackingError) def reset_spent_time(self, **kwargs: Any) -> Dict[str, Any]: """Resets the time spent working on the object. Loading @@ -904,7 +909,7 @@ class ParticipantsMixin(_RestObjectBase): _updated_attrs: Dict[str, Any] manager: base.RESTManager @cli.register_custom_action(("ProjectMergeRequest", "ProjectIssue")) @cli.register_custom_action(cls_names=("ProjectMergeRequest", "ProjectIssue")) @exc.on_http_error(exc.GitlabListError) def participants(self, **kwargs: Any) -> Dict[str, Any]: """List the participants. Loading Loading @@ -932,7 +937,8 @@ class ParticipantsMixin(_RestObjectBase): class BadgeRenderMixin(_RestManagerBase): @cli.register_custom_action( ("GroupBadgeManager", "ProjectBadgeManager"), ("link_url", "image_url") cls_names=("GroupBadgeManager", "ProjectBadgeManager"), required=("link_url", "image_url"), ) @exc.on_http_error(exc.GitlabRenderError) def render(self, link_url: str, image_url: str, **kwargs: Any) -> Dict[str, Any]: Loading Loading @@ -1025,7 +1031,9 @@ class UploadMixin(_RestObjectBase): data = self.attributes return self._upload_path.format(**data) @cli.register_custom_action(("Project", "ProjectWiki"), ("filename", "filepath")) @cli.register_custom_action( cls_names=("Project", "ProjectWiki"), required=("filename", "filepath") ) @exc.on_http_error(exc.GitlabUploadError) def upload( self, Loading
gitlab/v4/objects/artifacts.py +5 −2 Original line number Diff line number Diff line Loading @@ -44,7 +44,9 @@ class ProjectArtifactManager(RESTManager): self.gitlab.http_delete(path, **kwargs) @cli.register_custom_action( "ProjectArtifactManager", ("ref_name", "job"), ("job_token",) cls_names="ProjectArtifactManager", required=("ref_name", "job"), optional=("job_token",), ) @exc.on_http_error(exc.GitlabGetError) def download( Loading Loading @@ -93,7 +95,8 @@ class ProjectArtifactManager(RESTManager): ) @cli.register_custom_action( "ProjectArtifactManager", ("ref_name", "artifact_path", "job") cls_names="ProjectArtifactManager", required=("ref_name", "artifact_path", "job"), ) @exc.on_http_error(exc.GitlabGetError) def raw( Loading
gitlab/v4/objects/ci_lint.py +4 −4 Original line number Diff line number Diff line Loading @@ -31,8 +31,8 @@ class CiLintManager(CreateMixin, RESTManager): ) @register_custom_action( "CiLintManager", ("content",), cls_names="CiLintManager", required=("content",), optional=("include_merged_yaml", "include_jobs"), ) def validate(self, *args: Any, **kwargs: Any) -> None: Loading Loading @@ -63,8 +63,8 @@ class ProjectCiLintManager(GetWithoutIdMixin, CreateMixin, RESTManager): return cast(ProjectCiLint, super().get(**kwargs)) @register_custom_action( "ProjectCiLintManager", ("content",), cls_names="ProjectCiLintManager", required=("content",), optional=("dry_run", "include_jobs", "ref"), ) def validate(self, *args: Any, **kwargs: Any) -> None: Loading
gitlab/v4/objects/commits.py +6 −6 Original line number Diff line number Diff line Loading @@ -28,7 +28,7 @@ class ProjectCommit(RESTObject): discussions: ProjectCommitDiscussionManager statuses: "ProjectCommitStatusManager" @cli.register_custom_action("ProjectCommit") @cli.register_custom_action(cls_names="ProjectCommit") @exc.on_http_error(exc.GitlabGetError) def diff(self, **kwargs: Any) -> Union[gitlab.GitlabList, List[Dict[str, Any]]]: """Generate the commit diff. Loading @@ -46,7 +46,7 @@ class ProjectCommit(RESTObject): path = f"{self.manager.path}/{self.encoded_id}/diff" return self.manager.gitlab.http_list(path, **kwargs) @cli.register_custom_action("ProjectCommit", ("branch",)) @cli.register_custom_action(cls_names="ProjectCommit", required=("branch",)) @exc.on_http_error(exc.GitlabCherryPickError) def cherry_pick(self, branch: str, **kwargs: Any) -> None: """Cherry-pick a commit into a branch. Loading @@ -63,7 +63,7 @@ class ProjectCommit(RESTObject): post_data = {"branch": branch} self.manager.gitlab.http_post(path, post_data=post_data, **kwargs) @cli.register_custom_action("ProjectCommit", optional=("type",)) @cli.register_custom_action(cls_names="ProjectCommit", optional=("type",)) @exc.on_http_error(exc.GitlabGetError) def refs( self, type: str = "all", **kwargs: Any Loading @@ -85,7 +85,7 @@ class ProjectCommit(RESTObject): query_data = {"type": type} return self.manager.gitlab.http_list(path, query_data=query_data, **kwargs) @cli.register_custom_action("ProjectCommit") @cli.register_custom_action(cls_names="ProjectCommit") @exc.on_http_error(exc.GitlabGetError) def merge_requests( self, **kwargs: Any Loading @@ -105,7 +105,7 @@ class ProjectCommit(RESTObject): path = f"{self.manager.path}/{self.encoded_id}/merge_requests" return self.manager.gitlab.http_list(path, **kwargs) @cli.register_custom_action("ProjectCommit", ("branch",)) @cli.register_custom_action(cls_names="ProjectCommit", required=("branch",)) @exc.on_http_error(exc.GitlabRevertError) def revert( self, branch: str, **kwargs: Any Loading @@ -127,7 +127,7 @@ class ProjectCommit(RESTObject): post_data = {"branch": branch} return self.manager.gitlab.http_post(path, post_data=post_data, **kwargs) @cli.register_custom_action("ProjectCommit") @cli.register_custom_action(cls_names="ProjectCommit") @exc.on_http_error(exc.GitlabGetError) def signature(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]: """Get the signature of the commit. Loading