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("/tmp/myimage.jpg", "rb") as f:
article.upload_attachement(f, "myimage.jpg")
Download an attachment of an article#
After being uploaded, the attachment of an article can be retrieved through its upload id
article_metadata = article.get_data().get_metadata()
upload_attachment_id = article_metadata.get('attachments')[0].get("smartId")
attachment_res = article.get_uploaded_file(upload_attachment_id)
Moving an article in the taxonomy#
You can change the parent of an article
settings = wiki.get_settings()
settings.move_article_in_taxonomy(article.article_id, parent_article.article_id)
settings.save()
Changing the home article of the wiki#
settings = wiki.get_settings()
settings.set_home_article_id(article.article_id)
settings.save()
Reference documentation#
|
A handle to manage the wiki of a project |
|
Global settings for the wiki, including taxonomy. |
|
A handle to manage an article |
A handle to manage an article |