@@ -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 :
@@ -880,6 +891,11 @@ def Event(self, id=None, **kwargs):
880891 project_id = self .id ,
881892 ** kwargs )
882893
894+ def File (self , id = None , ** kwargs ):
895+ return self ._getListOrObject (ProjectFile , id ,
896+ project_id = self .id ,
897+ ** kwargs )
898+
883899 def Hook (self , id = None , ** kwargs ):
884900 return self ._getListOrObject (ProjectHook , id ,
885901 project_id = self .id ,
@@ -953,6 +969,30 @@ def archive(self, sha=None):
953969
954970 raise GitlabGetError
955971
972+ def create_file (self , path , branch , content , message ):
973+ url = "/projects/%s/repository/files" % self .id
974+ url += "?file_path=%s&branch_name=%s&content=%s&commit_message=%s" % \
975+ (path , branch , content , message )
976+ r = self .gitlab .rawPost (url )
977+ if r .status_code != 201 :
978+ raise GitlabCreateError
979+
980+ def update_file (self , path , branch , content , message ):
981+ url = "/projects/%s/repository/files" % self .id
982+ url += "?file_path=%s&branch_name=%s&content=%s&commit_message=%s" % \
983+ (path , branch , content , message )
984+ r = self .gitlab .rawPut (url )
985+ if r .status_code != 200 :
986+ raise GitlabUpdateError
987+
988+ def delete_file (self , path , branch , message ):
989+ url = "/projects/%s/repository/files" % self .id
990+ url += "?file_path=%s&branch_name=%s&commit_message=%s" % \
991+ (path , branch , message )
992+ r = self .gitlab .rawDelete (url )
993+ if r .status_code != 200 :
994+ raise GitlabDeleteError
995+
956996
957997class TeamMember (GitlabObject ):
958998 _url = '/user_teams/%(team_id)s/members'
0 commit comments