Discussion Service
Interact with Synapse discussion API endpoints.
-
class
challengeutils.discussion.
DiscussionApi
(syn: synapseclient.client.Synapse = None)[source] Bases:
object
Discussion API calls
-
delete_thread
(threadid: str)[source] Delete thread https://rest-docs.synapse.org/rest/DELETE/thread/threadId.html
-
get_forum
(forumid: str) → challengeutils.synapseservices.discussion.Forum[source] Get the Forum’s metadata for a given forum ID. https://rest-docs.synapse.org/rest/GET/forum/forumId.html
-
get_forum_moderators
(forumid: str) → Iterator[int][source] Get moderators given a forum ID https://rest-docs.synapse.org/rest/GET/forum/forumId/moderators.html
-
get_forum_threadcount
(forumid: str, query_filter: str = 'EXCLUDE_DELETED') → int[source] Total number of threads given forum ID https://rest-docs.synapse.org/rest/GET/forum/forumId/threadcount.html
-
get_forum_threads
(forumid: str, query_filter: str = 'EXCLUDE_DELETED', **kwargs) → Iterator[challengeutils.synapseservices.discussion.Thread][source] Get N number of threads for a given forum ID https://rest-docs.synapse.org/rest/GET/forum/forumId/threads.html
- Parameters
forumid – Forum ID
query_filter – filter forum threads returned. Can be NO_FILTER, DELETED_ONLY, EXCLUDE_DELETED. Defaults to EXCLUDE_DELETED.
- Yields
list – Forum threads
-
get_project_forum
(projectid: str) → challengeutils.synapseservices.discussion.Forum[source] Get the Forum’s metadata for a given project ID. https://rest-docs.synapse.org/rest/GET/project/projectId/forum.html
-
get_reply
(replyid: str) → challengeutils.synapseservices.discussion.Reply[source] Get a reply https://rest-docs.synapse.org/rest/GET/reply/replyId.html
-
get_reply_message_url
(messagekey: str) → dict[source] message URL of a thread. The message URL is the URL to download the file which contains the thread message. https://rest-docs.synapse.org/rest/GET/reply/messageUrl.html
-
get_thread
(threadid: str) → challengeutils.synapseservices.discussion.Thread[source] Get a thread and its statistic given its ID https://rest-docs.synapse.org/rest/GET/thread/threadId.html
-
get_thread_message_url
(messagekey: str) → dict[source] message URL of a thread. The message URL is the URL to download the file which contains the thread message. https://rest-docs.synapse.org/rest/GET/thread/messageUrl.html
-
get_thread_replies
(threadid: str, query_filter: str = 'EXCLUDE_DELETED', **kwargs)[source] Get N number of replies for a given thread ID https://rest-docs.synapse.org/rest/GET/thread/threadId/replies.html
- Parameters
threadid – Forum thread id
query_filter – filter forum thread replies returned. Can be NO_FILTER, DELETED_ONLY, EXCLUDE_DELETED. Defaults to EXCLUDE_DELETED.
- Yields
list – Forum threads replies
-
get_thread_replycount
(threadid: str, query_filter: str = 'EXCLUDE_DELETED') → int[source] Total number of replies given thread ID https://rest-docs.synapse.org/rest/GET/thread/threadId/replycount.html
-
get_threadcount_referencing_entities
(entityid_list: list) → list[source] Get list of entity and count pairs, with count is the number of threads that belongs to projects user can view and references the given entity. https://rest-docs.synapse.org/rest/POST/entity/threadcounts.html
-
get_threads_referencing_entity
(entityid: str, **kwargs) → Iterator[challengeutils.synapseservices.discussion.Thread][source] Get N number of threads that belongs to projects user can view and references the given entity https://rest-docs.synapse.org/rest/GET/entity/id/threads.html
- Parameters
syn – Synapse object
entityid – Synapse Entity id
- Yields
DiscussionThreadBundles
-
pin_thread
(threadid: str)[source] Pin a thread https://rest-docs.synapse.org/rest/PUT/thread/threadId/pin.html
-
post_reply
(threadid: str, message: str) → challengeutils.synapseservices.discussion.Reply[source] Create a new thread in a forum https://rest-docs.synapse.org/rest/POST/reply.html
- Parameters
threadid – Thread ID
message – Content of reply
- Returns
DiscussionReplyBundle
-
post_thread
(forumid: str, title: str, message: str) → challengeutils.synapseservices.discussion.Thread[source] Create a new thread in a forum https://rest-docs.synapse.org/rest/POST/thread.html
- Parameters
forumid – Forum ID
title – Title of thread
message – Content of thread
- Returns
DiscussionThreadBundle
-
restore_thread
(threadid: str)[source] Restore a deleted thread https://rest-docs.synapse.org/rest/PUT/thread/threadId/restore.html
-
unpin_thread
(threadid: str)[source] Unpin a thread https://rest-docs.synapse.org/rest/PUT/thread/threadId/unpin.html
-
update_thread_message
(threadid: str) → challengeutils.synapseservices.discussion.Thread[source] Update message of a thread https://rest-docs.synapse.org/rest/PUT/thread/threadId/message.html
-
update_thread_title
(threadid: str) → challengeutils.synapseservices.discussion.Thread[source] Update title of a thread https://rest-docs.synapse.org/rest/PUT/thread/threadId/title.html
-
-
challengeutils.discussion.
copy_forum
(syn: synapseclient.client.Synapse, project: Union[synapseclient.entity.Project, str], new_project: Union[synapseclient.entity.Project, str])[source] Copies the discussion forum of a project to another project
- Parameters
syn – synapse object
project – Synapse Project or its id
new_project – Synapse Project to copy forum to
-
challengeutils.discussion.
copy_reply
(syn, reply, thread)[source] Copies a discussion thread reply to a thread
- Parameters
syn – synapse object
reply – Synapse Reply
thread – Synapse thread or threadid to copy reply to
- Returns
Reply bundle
- Return type
dict
-
challengeutils.discussion.
copy_thread
(syn: synapseclient.client.Synapse, thread: challengeutils.synapseservices.discussion.Thread, project: Union[synapseclient.entity.Project, str]) → challengeutils.synapseservices.discussion.Thread[source] Copies a discussion thread and its replies to a project
- Parameters
syn – synapse object
thread – Synapse Thread
project – Synapse Project or its id to copy thread to
- Returns
Thread bundle
- Return type
dict
-
challengeutils.discussion.
create_thread
(syn, ent, title, message)[source] Create a thread
- Parameters
syn – synapse object
ent – Synapse Project entity or id
title – title of thread
message – message in thread
- Returns
Thread bundle
- Return type
dict
-
challengeutils.discussion.
create_thread_reply
(syn, threadid, message)[source] Creates a reply to a thread
- Parameters
syn – synapse object
threadid – Synapse Thread id
message – message in reply
- Returns
Reply bundle
- Return type
dict
-
challengeutils.discussion.
get_forum_participants
(syn: synapseclient.client.Synapse, ent: Union[synapseclient.entity.Project, str]) → List[synapseclient.team.UserProfile][source] Get all forum participants
- Parameters
ent – Synapse Project entity or id
synid – Synapse Project id
- Returns
user profiles active in forum
- Return type
list
-
challengeutils.discussion.
get_forum_threads
(syn: synapseclient.client.Synapse, ent: Union[synapseclient.entity.Project, str], **kwargs) → Iterator[challengeutils.synapseservices.discussion.Thread][source] Gets threads from a forum
- Parameters
syn – synapse object
ent – Synapse Project entity or id
**kwargs – query_filter - filter forum threads returned. Can be, NO_FILTER, DELETED_ONLY, EXCLUDE_DELETED. Defaults to EXCLUDE_DELETED. limit - Number of query results offset - Page of query result
- Yields
synapseservices.Thread
-
challengeutils.discussion.
get_thread_replies
(syn: synapseclient.client.Synapse, thread: challengeutils.synapseservices.discussion.Thread, **kwargs) → Iterator[challengeutils.synapseservices.discussion.Reply][source] Gets replies of a thread
- Parameters
syn – synapse object
thread – Synapse thread or id
**kwargs – query_filter: filter forum threads returned. Can be, NO_FILTER, DELETED_ONLY, EXCLUDE_DELETED. Defaults to EXCLUDE_DELETED. limit - Number of query results offset - Page of query result
- Yields
synapseservices.Reply
-
challengeutils.discussion.
get_thread_reply_text
(syn, reply: challengeutils.synapseservices.discussion.Reply) → str[source] Get thread reply text
- Parameters
syn – Synapse object
messagekey – Four part key from DiscussionReplyBundle.messageKey
- Returns
Thread text
- Return type
str
-
challengeutils.discussion.
get_thread_text
(syn: synapseclient.client.Synapse, thread: Union[challengeutils.synapseservices.discussion.Thread, str]) → str[source] Get a thread’s text
- Parameters
syn – Synapse object
thread – challengeutils.synapseservices.Thread or its id
- Returns
Thread text
- Return type
str