Skip to content

Commit 77647f6

Browse files
authored
Merge pull request #53 from dataiku/pbailly/ch45366/improve-wiki-python-public-api
Use the UUID of the page when saving a wiki article. [ch45366]
2 parents 804c0ed + f590967 commit 77647f6

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

dataikuapi/dss/wiki.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ def get_settings(self):
3030
"""
3131
return DSSWikiSettings(self.client, self.project_key, self.client._perform_json("GET", "/projects/%s/wiki/" % (self.project_key)))
3232

33-
def get_article(self, article_id):
33+
def get_article(self, article_id_or_name):
3434
"""
3535
Get a wiki article
3636
37-
:param str article_id: the article ID
37+
:param str article_id_or_name: reference to the article, it can be its ID or its name
3838
:returns: a handle to manage the Article
3939
:rtype: :class:`dataikuapi.dss.wiki.DSSWikiArticle`
4040
"""
41-
return DSSWikiArticle(self.client, self.project_key, article_id)
41+
return DSSWikiArticle(self.client, self.project_key, article_id_or_name)
4242

4343
def __flatten_taxonomy__(self, taxonomy):
4444
"""
@@ -206,11 +206,14 @@ class DSSWikiArticle(object):
206206
"""
207207
A handle to manage an article
208208
"""
209-
def __init__(self, client, project_key, article_id):
209+
def __init__(self, client, project_key, article_id_or_name):
210210
"""Do not call directly, use :meth:`dataikuapi.dss.wiki.DSSWiki.get_article`"""
211211
self.client = client
212212
self.project_key = project_key
213-
self.article_id = article_id
213+
214+
# Retrieve the real article id
215+
article_data = self.client._perform_json("GET", "/projects/%s/wiki/%s" % (project_key, article_id_or_name))
216+
self.article_id = article_data["article"]['id']
214217
# encode in UTF-8 if its python2 and unicode
215218
if sys.version_info < (3,0) and isinstance(self.article_id, unicode):
216219
self.article_id = self.article_id.encode('utf-8')
@@ -327,6 +330,6 @@ def set_name(self, name):
327330

328331
def save(self):
329332
"""
330-
Save the current article data to the backend
333+
Save the current article data to the backend.
331334
"""
332335
self.article_data = self.client._perform_json("PUT", "/projects/%s/wiki/%s" % (self.project_key, dku_quote_fn(self.article_id)), body=self.article_data)

0 commit comments

Comments
 (0)