@@ -129,6 +129,19 @@ def setCredentials(self, email, password):
129
129
self .email = email
130
130
self .password = password
131
131
132
+ def rawGet (self , path , with_token = False ):
133
+ url = '%s%s' % (self ._url , path )
134
+ if with_token :
135
+ url += "?private_token=%s" % self .private_token
136
+
137
+ try :
138
+ r = requests .get (url )
139
+ except :
140
+ raise GitlabConnectionError (
141
+ "Can't connect to GitLab server (%s)" % self ._url )
142
+
143
+ return r
144
+
132
145
def rawPost (self , path , data ):
133
146
url = '%s%s' % (self ._url , path )
134
147
try :
@@ -658,6 +671,16 @@ class ProjectSnippet(GitlabObject):
658
671
requiredCreateAttrs = ['project_id' , 'title' , 'file_name' , 'code' ]
659
672
optionalCreateAttrs = ['lifetime' ]
660
673
674
+ def Content (self ):
675
+ url = "/projects/%(project_id)s/snippets/%(snippet_id)s/raw" % \
676
+ {'project_id' : self .project_id , 'snippet_id' : self .id }
677
+ r = self .gitlab .rawGet (url , True )
678
+
679
+ if r .status_code == 200 :
680
+ return r .content
681
+ else :
682
+ raise GitlabGetError
683
+
661
684
def Note (self , id = None , ** kwargs ):
662
685
return self ._getListOrObject (ProjectSnippetNote , id ,
663
686
project_id = self .project_id ,
0 commit comments