Skip to content

Commit 0685de4

Browse files
committed
add synchronous protocol for wiki2
1 parent 1ce73fd commit 0685de4

File tree

1 file changed

+218
-0
lines changed

1 file changed

+218
-0
lines changed
Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
"""Protocol for the specific methods of this class that have synchronous counterparts
2+
generated at runtime."""
3+
4+
from typing import TYPE_CHECKING, List, Optional, Protocol
5+
6+
from synapseclient import Synapse
7+
8+
if TYPE_CHECKING:
9+
from synapseclient.models import (
10+
WikiHeader,
11+
WikiHistorySnapshot,
12+
WikiOrderHint,
13+
WikiPage,
14+
)
15+
16+
17+
class WikiOrderHintSynchronousProtocol(Protocol):
18+
"""Protocol for the methods of the WikiOrderHint class that have synchronous counterparts
19+
generated at runtime."""
20+
21+
def get(
22+
self,
23+
*,
24+
synapse_client: Optional[Synapse] = None,
25+
) -> WikiOrderHint:
26+
"""
27+
Get the order hint of a wiki page tree.
28+
Arguments:
29+
synapse_client: Optionally provide a Synapse client.
30+
Returns:
31+
A WikiOrderHint object for the entity.
32+
"""
33+
return self
34+
35+
def update(
36+
self,
37+
*,
38+
synapse_client: Optional["Synapse"] = None,
39+
) -> WikiOrderHint:
40+
"""
41+
Update the order hint of a wiki page tree.
42+
Arguments:
43+
synapse_client: Optionally provide a Synapse client.
44+
Returns:
45+
The updated WikiOrderHint object for the entity.
46+
"""
47+
return self
48+
49+
50+
class WikiHistorySnapshotSynchronousProtocol(Protocol):
51+
"""Protocol for the methods of the WikiHistorySnapshot class that have synchronous counterparts
52+
generated at runtime."""
53+
54+
@classmethod
55+
def get(
56+
cls,
57+
owner_id: str,
58+
wiki_id: str,
59+
*,
60+
offset: int = 0,
61+
limit: int = 20,
62+
synapse_client: Optional["Synapse"] = None,
63+
) -> List[WikiHistorySnapshot]:
64+
"""
65+
Get the history of a wiki page as a list of WikiHistorySnapshot objects.
66+
Arguments:
67+
owner_id: The ID of the owner entity.
68+
wiki_id: The ID of the wiki page.
69+
offset: The index of the pagination offset.
70+
limit: Limits the size of the page returned.
71+
synapse_client: Optionally provide a Synapse client.
72+
Returns:
73+
A list of WikiHistorySnapshot objects for the wiki page.
74+
"""
75+
return list({})
76+
77+
78+
class WikiHeaderSynchronousProtocol(Protocol):
79+
"""Protocol for the methods of the WikiHeader class that have synchronous counterparts
80+
generated at runtime."""
81+
82+
@classmethod
83+
def get(
84+
cls,
85+
owner_id: str,
86+
*,
87+
offset: int = 0,
88+
limit: int = 20,
89+
synapse_client: Optional["Synapse"] = None,
90+
) -> List[WikiHeader]:
91+
"""
92+
Get the header tree (hierarchy) of wiki pages for an entity.
93+
Arguments:
94+
owner_id: The ID of the owner entity.
95+
offset: The index of the pagination offset.
96+
limit: Limits the size of the page returned.
97+
synapse_client: Optionally provide a Synapse client.
98+
Returns:
99+
A list of WikiHeader objects for the entity.
100+
"""
101+
return list({})
102+
103+
104+
class WikiPageSynchronousProtocol(Protocol):
105+
"""Protocol for the methods of the WikiPage class that have synchronous counterparts
106+
generated at runtime."""
107+
108+
def create(
109+
self, *, synapse_client: Optional["Synapse"] = None, force_version: bool = False
110+
) -> WikiPage:
111+
"""
112+
Create a new wiki page.
113+
Arguments:
114+
synapse_client: Optionally provide a Synapse client.
115+
force_version: If True, the wiki page will be created with a new version number.
116+
Returns:
117+
The created WikiPage object.
118+
"""
119+
return self
120+
121+
def get(self, *, synapse_client: Optional["Synapse"] = None) -> WikiPage:
122+
"""
123+
Get a wiki page from Synapse asynchronously.
124+
Arguments:
125+
synapse_client: Optionally provide a Synapse client.
126+
Returns:
127+
The WikiPage object.
128+
"""
129+
return self
130+
131+
def update(
132+
self, *, force_version: bool = False, synapse_client: Optional["Synapse"] = None
133+
) -> WikiPage:
134+
"""
135+
Update a wiki page asynchronously. If force_version is True, restore a specific version of the content.
136+
Arguments:
137+
force_version: If True, update a specific version of the wiki page (restore).
138+
synapse_client: Optionally provide a Synapse client.
139+
Returns:
140+
The updated WikiPage object.
141+
"""
142+
return self
143+
144+
def delete(self, *, synapse_client: Optional["Synapse"] = None) -> None:
145+
"""
146+
Delete this wiki page.
147+
Arguments:
148+
synapse_client: Optionally provide a Synapse client.
149+
Returns:
150+
None
151+
"""
152+
return None
153+
154+
def get_attachment_handles(
155+
self, *, synapse_client: Optional["Synapse"] = None
156+
) -> list:
157+
"""
158+
Get the file handles of all attachments on this wiki page.
159+
Arguments:
160+
synapse_client: Optionally provide a Synapse client.
161+
Returns:
162+
The list of FileHandles for all file attachments of this WikiPage.
163+
"""
164+
return list([])
165+
166+
def get_attachment_url(
167+
self,
168+
file_name: str,
169+
*,
170+
redirect: Optional[bool] = False,
171+
synapse_client: Optional["Synapse"] = None,
172+
) -> dict:
173+
"""
174+
Get the URL of a wiki page attachment.
175+
Arguments:
176+
file_name: The name of the file to get.
177+
redirect: When set to false, the URL will be returned as text/plain instead of redirecting. Default is False.
178+
synapse_client: Optionally provide a Synapse client.
179+
Returns:
180+
The URL that can be used to download a file for a given WikiPage file attachment.
181+
"""
182+
return ""
183+
184+
def get_attachment_preview_url(
185+
self,
186+
file_name: str,
187+
*,
188+
wiki_version: Optional[int] = None,
189+
redirect: Optional[bool] = False,
190+
synapse_client: Optional["Synapse"] = None,
191+
) -> dict:
192+
"""
193+
Get the preview URL of a wiki page attachment asynchronously.
194+
Arguments:
195+
file_name: The name of the file to get.
196+
wiki_version: Optional version of the wiki page. If not provided, uses self.wiki_version.
197+
redirect: When set to false, the URL will be returned as text/plain instead of redirecting. Default is False.
198+
synapse_client: Optionally provide a Synapse client.
199+
Returns:
200+
The URL that can be used to download a preview file for a given WikiPage file attachment.
201+
"""
202+
return ""
203+
204+
def get_markdown_url_async(
205+
self,
206+
*,
207+
redirect: Optional[bool] = False,
208+
synapse_client: Optional["Synapse"] = None,
209+
) -> dict:
210+
"""
211+
Get the markdown URL of this wiki page asynchronously.
212+
Arguments:
213+
redirect: When set to false, the URL will be returned as text/plain instead of redirecting. Default is False.
214+
synapse_client: Optionally provide a Synapse client.
215+
Returns:
216+
The URL that can be used to download the markdown file for this WikiPage.
217+
"""
218+
return ""

0 commit comments

Comments
 (0)