33
44import requests
55
6- from gitlab import cli
6+ from gitlab import base , cli
77from gitlab import exceptions as exc
88from gitlab import utils
99from gitlab .base import RequiredOptional , RESTManager , RESTObject
@@ -95,7 +95,8 @@ class ProjectFileManager(GetMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTMa
9595 optional = ("encoding" , "author_email" , "author_name" ),
9696 )
9797
98- @cli .register_custom_action ("ProjectFileManager" , ("file_path" , "ref" ))
98+ @cli .register_custom_action ("ProjectFileManager" )
99+ @base .custom_attrs (required = ("file_path" , "ref" ))
99100 # NOTE(jlvillal): Signature doesn't match UpdateMixin.update() so ignore
100101 # type error
101102 def get ( # type: ignore
@@ -117,10 +118,10 @@ def get( # type: ignore
117118 """
118119 return cast (ProjectFile , GetMixin .get (self , file_path , ref = ref , ** kwargs ))
119120
120- @cli .register_custom_action (
121- "ProjectFileManager" ,
122- ("file_path" , "branch" , "content" , "commit_message" ),
123- ("encoding" , "author_email" , "author_name" ),
121+ @cli .register_custom_action ("ProjectFileManager" )
122+ @ base . custom_attrs (
123+ required = ("file_path" , "branch" , "content" , "commit_message" ),
124+ optional = ("encoding" , "author_email" , "author_name" ),
124125 )
125126 @exc .on_http_error (exc .GitlabCreateError )
126127 def create (
@@ -184,9 +185,8 @@ def update( # type: ignore
184185 assert isinstance (result , dict )
185186 return result
186187
187- @cli .register_custom_action (
188- "ProjectFileManager" , ("file_path" , "branch" , "commit_message" )
189- )
188+ @cli .register_custom_action ("ProjectFileManager" )
189+ @base .custom_attrs (required = ("file_path" , "branch" , "commit_message" ))
190190 @exc .on_http_error (exc .GitlabDeleteError )
191191 # NOTE(jlvillal): Signature doesn't match DeleteMixin.delete() so ignore
192192 # type error
@@ -210,7 +210,8 @@ def delete( # type: ignore
210210 data = {"branch" : branch , "commit_message" : commit_message }
211211 self .gitlab .http_delete (path , query_data = data , ** kwargs )
212212
213- @cli .register_custom_action ("ProjectFileManager" , ("file_path" , "ref" ))
213+ @cli .register_custom_action ("ProjectFileManager" )
214+ @base .custom_attrs (required = ("file_path" , "ref" ))
214215 @exc .on_http_error (exc .GitlabGetError )
215216 def raw (
216217 self ,
@@ -251,7 +252,8 @@ def raw(
251252 assert isinstance (result , requests .Response )
252253 return utils .response_content (result , streamed , action , chunk_size )
253254
254- @cli .register_custom_action ("ProjectFileManager" , ("file_path" , "ref" ))
255+ @cli .register_custom_action ("ProjectFileManager" )
256+ @base .custom_attrs (required = ("file_path" , "ref" ))
255257 @exc .on_http_error (exc .GitlabListError )
256258 def blame (self , file_path : str , ref : str , ** kwargs : Any ) -> List [Dict [str , Any ]]:
257259 """Return the content of a file for a commit.
0 commit comments