3
3
4
4
import requests
5
5
6
- from gitlab import cli
6
+ from gitlab import base , cli
7
7
from gitlab import exceptions as exc
8
8
from gitlab import utils
9
9
from gitlab .base import RESTManager ,RESTObject
@@ -98,7 +98,8 @@ class ProjectFileManager(GetMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTMa
98
98
optional = ("encoding" ,"author_email" ,"author_name" ),
99
99
)
100
100
101
- @cli .register_custom_action ("ProjectFileManager" , ("file_path" ,"ref" ))
101
+ @cli .register_custom_action ("ProjectFileManager" )
102
+ @base .custom_attrs (required = ("file_path" ,"ref" ))
102
103
# NOTE(jlvillal): Signature doesn't match UpdateMixin.update() so ignore
103
104
# type error
104
105
def get (# type: ignore
@@ -120,10 +121,10 @@ def get( # type: ignore
120
121
"""
121
122
return cast (ProjectFile ,GetMixin .get (self ,file_path ,ref = ref ,** kwargs ))
122
123
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" ),
127
128
)
128
129
@exc .on_http_error (exc .GitlabCreateError )
129
130
def create (
@@ -187,9 +188,8 @@ def update( # type: ignore
187
188
assert isinstance (result ,dict )
188
189
return result
189
190
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" ))
193
193
@exc .on_http_error (exc .GitlabDeleteError )
194
194
# NOTE(jlvillal): Signature doesn't match DeleteMixin.delete() so ignore
195
195
# type error
@@ -213,7 +213,8 @@ def delete( # type: ignore
213
213
data = {"branch" :branch ,"commit_message" :commit_message }
214
214
self .gitlab .http_delete (path ,query_data = data ,** kwargs )
215
215
216
- @cli .register_custom_action ("ProjectFileManager" , ("file_path" ,"ref" ))
216
+ @cli .register_custom_action ("ProjectFileManager" )
217
+ @base .custom_attrs (required = ("file_path" ,"ref" ))
217
218
@exc .on_http_error (exc .GitlabGetError )
218
219
def raw (
219
220
self ,
@@ -254,7 +255,8 @@ def raw(
254
255
assert isinstance (result ,requests .Response )
255
256
return utils .response_content (result ,streamed ,action ,chunk_size )
256
257
257
- @cli .register_custom_action ("ProjectFileManager" , ("file_path" ,"ref" ))
258
+ @cli .register_custom_action ("ProjectFileManager" )
259
+ @base .custom_attrs (required = ("file_path" ,"ref" ))
258
260
@exc .on_http_error (exc .GitlabListError )
259
261
def blame (self ,file_path :str ,ref :str ,** kwargs :Any )-> List [Dict [str ,Any ]]:
260
262
"""Return the content of a file for a commit.