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 RESTManager ,RESTObject
@@ -98,7 +98,8 @@ class ProjectFileManager(GetMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTMa
9898optional = ("encoding" ,"author_email" ,"author_name" ),
9999 )
100100
101- @cli .register_custom_action ("ProjectFileManager" , ("file_path" ,"ref" ))
101+ @cli .register_custom_action ("ProjectFileManager" )
102+ @base .custom_attrs (required = ("file_path" ,"ref" ))
102103# NOTE(jlvillal): Signature doesn't match UpdateMixin.update() so ignore
103104# type error
104105def get (# type: ignore
@@ -120,10 +121,10 @@ def get( # type: ignore
120121 """
121122return cast (ProjectFile ,GetMixin .get (self ,file_path ,ref = ref ,** kwargs ))
122123
123- @cli .register_custom_action (
124- "ProjectFileManager" ,
125- ("file_path" ,"branch" ,"content" ,"commit_message" ),
126- ("encoding" ,"author_email" ,"author_name" ),
124+ @cli .register_custom_action ("ProjectFileManager" )
125+ @ base . custom_attrs (
126+ required = ("file_path" ,"branch" ,"content" ,"commit_message" ),
127+ optional = ("encoding" ,"author_email" ,"author_name" ),
127128 )
128129@exc .on_http_error (exc .GitlabCreateError )
129130def create (
@@ -187,9 +188,8 @@ def update( # type: ignore
187188assert isinstance (result ,dict )
188189return result
189190
190- @cli .register_custom_action (
191- "ProjectFileManager" , ("file_path" ,"branch" ,"commit_message" )
192- )
191+ @cli .register_custom_action ("ProjectFileManager" )
192+ @base .custom_attrs (required = ("file_path" ,"branch" ,"commit_message" ))
193193@exc .on_http_error (exc .GitlabDeleteError )
194194# NOTE(jlvillal): Signature doesn't match DeleteMixin.delete() so ignore
195195# type error
@@ -213,7 +213,8 @@ def delete( # type: ignore
213213data = {"branch" :branch ,"commit_message" :commit_message }
214214self .gitlab .http_delete (path ,query_data = data ,** kwargs )
215215
216- @cli .register_custom_action ("ProjectFileManager" , ("file_path" ,"ref" ))
216+ @cli .register_custom_action ("ProjectFileManager" )
217+ @base .custom_attrs (required = ("file_path" ,"ref" ))
217218@exc .on_http_error (exc .GitlabGetError )
218219def raw (
219220self ,
@@ -254,7 +255,8 @@ def raw(
254255assert isinstance (result ,requests .Response )
255256return utils .response_content (result ,streamed ,action ,chunk_size )
256257
257- @cli .register_custom_action ("ProjectFileManager" , ("file_path" ,"ref" ))
258+ @cli .register_custom_action ("ProjectFileManager" )
259+ @base .custom_attrs (required = ("file_path" ,"ref" ))
258260@exc .on_http_error (exc .GitlabListError )
259261def blame (self ,file_path :str ,ref :str ,** kwargs :Any )-> List [Dict [str ,Any ]]:
260262"""Return the content of a file for a commit.