summaryrefslogtreecommitdiff
path: root/docs/gl_objects/projects.py
diff options
context:
space:
mode:
authorGauvain Pocentek <gauvain@pocentek.net>2016-08-09 16:37:45 +0200
committerGauvain Pocentek <gauvain@pocentek.net>2016-08-09 16:37:45 +0200
commitf00340f72935b6fd80df7b62b811644b63049b5a (patch)
tree5cb0428f95121d237534af7f76bb600436db94d2 /docs/gl_objects/projects.py
parent71a2a4fb84321e73418fda1ce4e4d47177af928c (diff)
downloadgitlab-f00340f72935b6fd80df7b62b811644b63049b5a.tar.gz
docs: repository files API
Diffstat (limited to 'docs/gl_objects/projects.py')
-rw-r--r--docs/gl_objects/projects.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/docs/gl_objects/projects.py b/docs/gl_objects/projects.py
index 6a7cb6d..958298c 100644
--- a/docs/gl_objects/projects.py
+++ b/docs/gl_objects/projects.py
@@ -194,3 +194,51 @@ tgz = project.repository_archive(sha='4567abc')
# repository contributors
contributors = project.repository_contributors()
# end repository contributors
+
+# files get
+f = gl.project_files.get(file_path='README.rst', ref='master',
+ project_id=1)
+# or
+f = project.files.get(file_path='README.rst', ref='master')
+
+# get the base64 encoded content
+print(f.content)
+
+# get the decoded content
+print(f.decode())
+# end files get
+
+# files create
+f = gl.project_files.create({'file_path': 'testfile',
+ 'branch_name': 'master',
+ 'content': file_content,
+ 'commit_message': 'Create testfile'},
+ project_id=1)
+# or
+f = project.files.create({'file_path': 'testfile',
+ 'branch_name': 'master',
+ 'content': file_content,
+ 'commit_message': 'Create testfile'})
+# end files create
+
+# files update
+f.content = 'new content'
+f.save(branch='master', commit_message='Update testfile')
+
+# or for binary data
+f.content = base64.b64encode(open('image.png').read())
+f.save(branch='master', commit_message='Update testfile', encoding='base64')
+# end files update
+
+# files delete
+gl.project_files.delete({'file_path': 'testfile',
+ 'branch_name': 'master',
+ 'commit_message': 'Delete testfile'},
+ project_id=1)
+# or
+project.files.delete({'file_path': 'testfile',
+ 'branch_name': 'master',
+ 'commit_message': 'Delete testfile'})
+# or
+f.delete(commit_message='Delete testfile')
+# end files delete