@@ -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 :
@@ -880,6 +891,11 @@ def Event(self, id=None, **kwargs):
880
891
project_id = self .id ,
881
892
** kwargs )
882
893
894
+ def File (self , id = None , ** kwargs ):
895
+ return self ._getListOrObject (ProjectFile , id ,
896
+ project_id = self .id ,
897
+ ** kwargs )
898
+
883
899
def Hook (self , id = None , ** kwargs ):
884
900
return self ._getListOrObject (ProjectHook , id ,
885
901
project_id = self .id ,
@@ -953,6 +969,30 @@ def archive(self, sha=None):
953
969
954
970
raise GitlabGetError
955
971
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
+
956
996
957
997
class TeamMember (GitlabObject ):
958
998
_url = '/user_teams/%(team_id)s/members'
0 commit comments