Skip to content

Commit 99ac7da

Browse files
committed
read the docs for changes. Fixes pyapi-gitlab#14
1 parent 5da9bc7 commit 99ac7da

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

docs/index.rst

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ Then we need to authenticate to our Gitlab instance. There is 2 ways of doing th
2626
Authenticating via user/password
2727
==================================
2828

29-
First create the instance passing the gitlab server as parameter::
29+
First create the instance passing the gitlab server as parameter, You can also pass the gitlab backend version as there are some differences
30+
between 5 and 6 (One example, when creating projects you cna make them public on gitlab 6, gitlab 5 doesn't have that option) default version is 5::
3031

31-
git = gitlab.Gitlab("our_gitlab_host")
32+
git = gitlab.Gitlab("our_gitlab_host","5")
3233

3334
Then call the login() method::
3435

@@ -110,9 +111,14 @@ Get project events::
110111

111112
git.getProjectEvents(project_id)
112113

113-
Create a new project::
114+
Create a new project
115+
If you are using version 6 you can pass an extra "public" argument which makes the project public.
116+
Please note that Gitlab 5 doesn't have this option and you have to explicity declare your version of gitlab (See the start of the docs to find how)::
114117

115-
git.createProject("test project number 1")
118+
git.createProject(name, description="", default_branch="",
119+
issues_enabled="", wall_enabled="",
120+
merge_requests_enabled="", wiki_enabled="",
121+
snippets_enabled="", public="")
116122

117123
List project members::
118124

gitlab/__init__.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
class Gitlab(object):
14-
def __init__(self, host, token=""):
14+
def __init__(self, host, token="", version=5):
1515
if token != "":
1616
self.token = token
1717
self.headers = {"PRIVATE-TOKEN": self.token}
@@ -20,6 +20,7 @@ def __init__(self, host, token=""):
2020
self.users_url = self.host + "/api/v3/users"
2121
self.keys_url = self.host + "/api/v3/user/keys"
2222
self.groups_url = self.host + "/api/v3/groups"
23+
self.version = version
2324

2425
def login(self, email, password):
2526
data = {"email": email, "password": password}
@@ -252,7 +253,7 @@ def getProjectEvents(self, id_):
252253
def createProject(self, name, description="", default_branch="",
253254
issues_enabled="", wall_enabled="",
254255
merge_requests_enabled="", wiki_enabled="",
255-
snippets_enabled=""):
256+
snippets_enabled="", public=""):
256257
"""
257258
Create a project
258259
:param name: Obligatory
@@ -265,6 +266,11 @@ def createProject(self, name, description="", default_branch="",
265266
"merge_requests_enabled": merge_requests_enabled,
266267
"wiki_enabled": wiki_enabled,
267268
"snippets_enabled": snippets_enabled}
269+
270+
# if gitlab is the new 6th version, there is a public option for the
271+
# project creation
272+
if self.version == 6:
273+
data['public'] = public
268274
r = requests.post(self.projects_url, headers=self.headers, data=data)
269275
if r.status_code == 201:
270276
return json.loads(r.content)

0 commit comments

Comments
 (0)