Wikis

You can interact with the Wiki of each project through the API.

Getting the DSSWiki object

You must first retrieve the DSSWiki through the get_wiki() method

project = client.get_project("MYPROJECT")
wiki = project.get_wiki()

Retrieving and modifying the content of an article

article = wiki.get_article("article_name")
article_data = article.get_data()

# Modify the content of the article data
current_markdown_content = article_data.get_body()
article_data.set_body("# My new Markdown content")

# And save the modified content
article_data.save()

Deleting an article

article = wiki.get_article("article_name")
article.delete()

Getting the list of all articles

This prints the content of all articles in the Wiki

for article in wiki.list_articles():
        print("Article: %s" % article.article_id)
        article_data = article.get_data()
        print("Content:")
        print(article_data.get_body())

Uploading an attachment to an article

After upload, the attachment can be referenced through the Markdown syntax

article = wiki.get_article("article_name")

with open("myimage.jpg") as f:
        article.upload_attachment(f, "myimage.jpg")

Moving an article in the taxonomy

You can change the parent of an article

settings = wiki.get_settings()
settings.move_article_in_taxonomy("article_name", "new_parent_of_the_article")
settings.save()

Changing the home article of the wiki

settings = wiki.get_settings()
settings.set_home_article_id("new_home_article")
settings.save()

Reference documentation

class dataikuapi.dss.wiki.DSSWiki(client, project_key)

A handle to manage the wiki of a project

get_settings()

Get wiki settings

Returns

a handle to manage the wiki settings (taxonomy, home article)

Return type

dataikuapi.dss.wiki.DSSWikiSettings

get_article(article_id_or_name)

Get a wiki article

Parameters

article_id_or_name (str) – reference to the article, it can be its ID or its name

Returns

a handle to manage the Article

Return type

dataikuapi.dss.wiki.DSSWikiArticle

list_articles()

Get a list of all the articles in form of dataikuapi.dss.wiki.DSSWikiArticle objects

Returns

list of articles

Return type

list of dataikuapi.dss.wiki.DSSWikiArticle

create_article(article_name, parent_id=None, content=None)

Create a wiki article

Parameters
  • article_name (str) – the article name

  • parent_id (str) – the parent article ID (or None if the article has to be at root level)

  • content (str) – the article content

Returns

the created article

Return type

dataikuapi.dss.wiki.DSSWikiArticle

get_export_stream(paper_size='A4', export_attachment=False)

Download the whole wiki of the project in PDF format as a binary stream. Warning: this stream will monopolize the DSSClient until closed.

Parameters
  • paper_size (str) – the format of the exported page, can be one of ‘A4’, ‘A3’, ‘US_LETTER’ or ‘LEDGER’

  • export_attachment (bool) – export the attachments of the article(s) in addition to the pdf in a zip file

Returns

the exported pdf or zip file as a stream

export_to_file(path, paper_size='A4', export_attachment=False)

Download the whole wiki of the project in PDF format into the given output file.

Parameters
  • paper_size (str) – the format of the exported page, can be one of ‘A4’, ‘A3’, ‘US_LETTER’ or ‘LEDGER’

  • export_attachment (bool) – export the attachments of the article(s) in addition to the pdf in a zip file

class dataikuapi.dss.wiki.DSSWikiSettings(client, project_key, settings)

Global settings for the wiki, including taxonomy. Call save() to save

get_taxonomy()

Get the taxonomy The taxonomy is an array listing at top level the root article IDs and their children in a tree format. Every existing article of the wiki has to be in the taxonomy once and only once. For instance: [

{

‘id’: ‘article1’, ‘children’: []

}, {

‘id’: ‘article2’, ‘children’: [

{

‘id’: ‘article3’, ‘children’: []

}

]

}

] Note that this is a direct reference, not a copy, so modifications to the returned object will be reflected when saving

Returns

The taxonomy

Return type

list

move_article_in_taxonomy(article_id, parent_article_id=None)

An helper to update the taxonomy by moving an article with its children as a child of another article

Parameters
  • article_id (str) – the main article ID

  • parent_article_id (str) – the new parent article ID or None for root level

set_taxonomy(taxonomy)

Set the taxonomy

Parameters

taxonomy (list) – the taxonomy

get_home_article_id()

Get the home article ID

Returns

The home article ID

Return type

str

set_home_article_id(home_article_id)

Set the home article ID

Parameters

home_article_id (str) – the home article ID

save()

Save the current settings to the backend

class dataikuapi.dss.wiki.DSSWikiArticle(client, project_key, article_id_or_name)

A handle to manage an article

get_data()

” Get article data handle

Returns

the article data handle

Return type

dataikuapi.dss.wiki.DSSWikiArticleData

upload_attachement(fp, filename)

Upload an attachment file and attaches it to the article Note that the type of file will be determined by the filename extension

Parameters
  • fp (file) – A file-like object that represents the upload file

  • filename (str) – The attachement filename

get_uploaded_file(upload_id)

” Download the attachement of an article

Parameters

upload_id (str) – The attachement upload id

Returns

The requests.Response object

Return type

requests.Response

get_export_stream(paper_size='A4', export_children=False, export_attachment=False)

Download the article in PDF format as a binary stream. Warning: this stream will monopolize the DSSClient until closed.

Parameters
  • path (str) – the path of the file where the pdf or zip file will be downloaded

  • paper_size (str) – the format of the exported page, can be one of ‘A4’, ‘A3’, ‘US_LETTER’ or ‘LEDGER’

  • export_children (bool) – export the children of the article in the pdf

  • export_attachment (bool) – export the attachments of the article(s) in addition to the pdf in a zip file

Returns

the exported pdf or zip file as a stream

export_to_file(path, paper_size='A4', export_children=False, export_attachment=False)

Download the article in PDF format into the given output file.

Parameters
  • paper_size (str) – the format of the exported page, can be one of ‘A4’, ‘A3’, ‘US_LETTER’ or ‘LEDGER’

  • export_children (bool) – export the children of the article in the pdf

  • export_attachment (bool) – export the attachments of the article(s) in addition to the pdf in a zip file

delete()

Delete the article

get_object_discussions()

Get a handle to manage discussions on the article

Returns

the handle to manage discussions

Return type

dataikuapi.dss.wiki.DSSObjectDiscussions

class dataikuapi.dss.wiki.DSSWikiArticleData(client, project_key, article_id, article_data)

A handle to manage an article

get_body()

Get the markdown body as string

Returns

the article body

Return type

str

set_body(content)

Set the markdown body

Parameters

content (str) – the article content

get_metadata()

Get the article metadata Note that this is a direct reference, not a copy, so modifications to the returned object will be reflected when saving

Returns

the article metadata

Return type

dict

set_metadata(metadata)

Set the article metadata

Parameters

metadata (dict) – the article metadata

get_name()

Get the article name

Returns

the article name

Return type

str

set_name(name)

Set the article name

Parameters

name (str) – the article name

save()

Save the current article data to the backend.