@@ -141,7 +141,7 @@ def rawGet(self, path):
141
141
raise GitlabConnectionError (
142
142
"Can't connect to GitLab server (%s)" % self ._url )
143
143
144
- def rawPost (self , path , data ):
144
+ def rawPost (self , path , data = None ):
145
145
url = '%s%s' % (self ._url , path )
146
146
try :
147
147
return requests .post (url , data ,
@@ -162,6 +162,17 @@ def rawPut(self, path):
162
162
raise GitlabConnectionError (
163
163
"Can't connect to GitLab server (%s)" % self ._url )
164
164
165
+ def rawDelete (self , path ):
166
+ url = '%s%s' % (self ._url , path )
167
+
168
+ try :
169
+ return requests .delete (url ,
170
+ headers = self .headers ,
171
+ verify = self .ssl_verify )
172
+ except :
173
+ raise GitlabConnectionError (
174
+ "Can't connect to GitLab server (%s)" % self ._url )
175
+
165
176
def list (self , obj_class , ** kwargs ):
166
177
missing = []
167
178
for k in obj_class .requiredListAttrs :
@@ -907,6 +918,11 @@ def Event(self, id=None, **kwargs):
907
918
project_id = self .id ,
908
919
** kwargs )
909
920
921
+ def File (self , id = None , ** kwargs ):
922
+ return self ._getListOrObject (ProjectFile , id ,
923
+ project_id = self .id ,
924
+ ** kwargs )
925
+
910
926
def Hook (self , id = None , ** kwargs ):
911
927
return self ._getListOrObject (ProjectHook , id ,
912
928
project_id = self .id ,
@@ -980,6 +996,30 @@ def archive(self, sha=None):
980
996
981
997
raise GitlabGetError
982
998
999
+ def create_file (self , path , branch , content , message ):
1000
+ url = "/projects/%s/repository/files" % self .id
1001
+ url += "?file_path=%s&branch_name=%s&content=%s&commit_message=%s" % \
1002
+ (path , branch , content , message )
1003
+ r = self .gitlab .rawPost (url )
1004
+ if r .status_code != 201 :
1005
+ raise GitlabCreateError
1006
+
1007
+ def update_file (self , path , branch , content , message ):
1008
+ url = "/projects/%s/repository/files" % self .id
1009
+ url += "?file_path=%s&branch_name=%s&content=%s&commit_message=%s" % \
1010
+ (path , branch , content , message )
1011
+ r = self .gitlab .rawPut (url )
1012
+ if r .status_code != 200 :
1013
+ raise GitlabUpdateError
1014
+
1015
+ def delete_file (self , path , branch , message ):
1016
+ url = "/projects/%s/repository/files" % self .id
1017
+ url += "?file_path=%s&branch_name=%s&commit_message=%s" % \
1018
+ (path , branch , message )
1019
+ r = self .gitlab .rawDelete (url )
1020
+ if r .status_code != 200 :
1021
+ raise GitlabDeleteError
1022
+
983
1023
984
1024
class TeamMember (GitlabObject ):
985
1025
_url = '/user_teams/%(team_id)s/members'
0 commit comments