@@ -141,7 +141,7 @@ def rawGet(self, path):
141141 raise GitlabConnectionError (
142142 "Can't connect to GitLab server (%s)" % self ._url )
143143
144- def rawPost (self , path , data ):
144+ def rawPost (self , path , data = None ):
145145 url = '%s%s' % (self ._url , path )
146146 try :
147147 return requests .post (url , data ,
@@ -162,6 +162,17 @@ def rawPut(self, path):
162162 raise GitlabConnectionError (
163163 "Can't connect to GitLab server (%s)" % self ._url )
164164
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+
165176 def list (self , obj_class , ** kwargs ):
166177 missing = []
167178 for k in obj_class .requiredListAttrs :
@@ -907,6 +918,11 @@ def Event(self, id=None, **kwargs):
907918 project_id = self .id ,
908919 ** kwargs )
909920
921+ def File (self , id = None , ** kwargs ):
922+ return self ._getListOrObject (ProjectFile , id ,
923+ project_id = self .id ,
924+ ** kwargs )
925+
910926 def Hook (self , id = None , ** kwargs ):
911927 return self ._getListOrObject (ProjectHook , id ,
912928 project_id = self .id ,
@@ -980,6 +996,30 @@ def archive(self, sha=None):
980996
981997 raise GitlabGetError
982998
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+
9831023
9841024class TeamMember (GitlabObject ):
9851025 _url = '/user_teams/%(team_id)s/members'
0 commit comments