Skip to content

Commit a620db5

Browse files
committed
update function names
1 parent 47f38e0 commit a620db5

File tree

1 file changed

+38
-34
lines changed

1 file changed

+38
-34
lines changed

synapseclient/models/protocols/wikipage_protocol.py

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
"""Protocol for the specific methods of this class that have synchronous counterparts
22
generated at runtime."""
33

4-
from typing import TYPE_CHECKING, List, Optional, Protocol
4+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Protocol, Union
55

66
from synapseclient import Synapse
7+
from synapseclient.core.async_utils import async_to_sync
78

89
if TYPE_CHECKING:
910
from synapseclient.models import (
@@ -14,6 +15,7 @@
1415
)
1516

1617

18+
@async_to_sync
1719
class WikiOrderHintSynchronousProtocol(Protocol):
1820
"""Protocol for the methods of the WikiOrderHint class that have synchronous counterparts
1921
generated at runtime."""
@@ -22,7 +24,7 @@ def get(
2224
self,
2325
*,
2426
synapse_client: Optional[Synapse] = None,
25-
) -> WikiOrderHint:
27+
) -> "WikiOrderHint":
2628
"""
2729
Get the order hint of a wiki page tree.
2830
Arguments:
@@ -32,11 +34,11 @@ def get(
3234
"""
3335
return self
3436

35-
def update(
37+
def store(
3638
self,
3739
*,
3840
synapse_client: Optional["Synapse"] = None,
39-
) -> WikiOrderHint:
41+
) -> "WikiOrderHint":
4042
"""
4143
Update the order hint of a wiki page tree.
4244
Arguments:
@@ -47,6 +49,7 @@ def update(
4749
return self
4850

4951

52+
@async_to_sync
5053
class WikiHistorySnapshotSynchronousProtocol(Protocol):
5154
"""Protocol for the methods of the WikiHistorySnapshot class that have synchronous counterparts
5255
generated at runtime."""
@@ -60,7 +63,7 @@ def get(
6063
offset: int = 0,
6164
limit: int = 20,
6265
synapse_client: Optional["Synapse"] = None,
63-
) -> List[WikiHistorySnapshot]:
66+
) -> List["WikiHistorySnapshot"]:
6467
"""
6568
Get the history of a wiki page as a list of WikiHistorySnapshot objects.
6669
Arguments:
@@ -75,6 +78,7 @@ def get(
7578
return list({})
7679

7780

81+
@async_to_sync
7882
class WikiHeaderSynchronousProtocol(Protocol):
7983
"""Protocol for the methods of the WikiHeader class that have synchronous counterparts
8084
generated at runtime."""
@@ -87,7 +91,7 @@ def get(
8791
offset: int = 0,
8892
limit: int = 20,
8993
synapse_client: Optional["Synapse"] = None,
90-
) -> List[WikiHeader]:
94+
) -> List["WikiHeader"]:
9195
"""
9296
Get the header tree (hierarchy) of wiki pages for an entity.
9397
Arguments:
@@ -101,43 +105,39 @@ def get(
101105
return list({})
102106

103107

108+
@async_to_sync
104109
class WikiPageSynchronousProtocol(Protocol):
105110
"""Protocol for the methods of the WikiPage class that have synchronous counterparts
106111
generated at runtime."""
107112

108-
def create(
109-
self, *, synapse_client: Optional["Synapse"] = None, force_version: bool = False
110-
) -> WikiPage:
113+
def store(self, *, synapse_client: Optional["Synapse"] = None) -> "WikiPage":
111114
"""
112-
Create a new wiki page.
115+
Store the wiki page. If there is no wiki page, a new wiki page will be created.
116+
If the wiki page already exists, it will be updated.
113117
Arguments:
114118
synapse_client: Optionally provide a Synapse client.
115-
force_version: If True, the wiki page will be created with a new version number.
116119
Returns:
117120
The created WikiPage object.
118121
"""
119122
return self
120123

121-
def get(self, *, synapse_client: Optional["Synapse"] = None) -> WikiPage:
124+
def restore(self, *, synapse_client: Optional["Synapse"] = None) -> "WikiPage":
122125
"""
123-
Get a wiki page from Synapse asynchronously.
126+
Restore a specific version of the wiki page.
124127
Arguments:
125128
synapse_client: Optionally provide a Synapse client.
126129
Returns:
127-
The WikiPage object.
130+
The restored WikiPage object.
128131
"""
129132
return self
130133

131-
def update(
132-
self, *, force_version: bool = False, synapse_client: Optional["Synapse"] = None
133-
) -> WikiPage:
134+
def get(self, *, synapse_client: Optional["Synapse"] = None) -> "WikiPage":
134135
"""
135-
Update a wiki page asynchronously. If force_version is True, restore a specific version of the content.
136+
Get a wiki page from Synapse.
136137
Arguments:
137-
force_version: If True, update a specific version of the wiki page (restore).
138138
synapse_client: Optionally provide a Synapse client.
139139
Returns:
140-
The updated WikiPage object.
140+
The WikiPage object.
141141
"""
142142
return self
143143

@@ -153,66 +153,70 @@ def delete(self, *, synapse_client: Optional["Synapse"] = None) -> None:
153153

154154
def get_attachment_handles(
155155
self, *, synapse_client: Optional["Synapse"] = None
156-
) -> list:
156+
) -> List[Dict[str, Any]]:
157157
"""
158158
Get the file handles of all attachments on this wiki page.
159159
Arguments:
160160
synapse_client: Optionally provide a Synapse client.
161161
Returns:
162162
The list of FileHandles for all file attachments of this WikiPage.
163163
"""
164-
return list([])
164+
return list({})
165165

166-
def get_attachment_url(
166+
def get_attachment(
167167
self,
168168
file_name: str,
169169
*,
170+
download_file: bool = True,
171+
download_location: Optional[str] = None,
170172
redirect: Optional[bool] = False,
171173
synapse_client: Optional["Synapse"] = None,
172-
) -> dict:
174+
) -> Union[str, None]:
173175
"""
174-
Get the URL of a wiki page attachment.
176+
Download the wiki page attachment to a local file or return the URL.
175177
Arguments:
176178
file_name: The name of the file to get.
179+
download_file: Whether to download the file. Default is True.
180+
download_location: The location to download the file to. Required if download_file is True.
177181
redirect: When set to false, the URL will be returned as text/plain instead of redirecting. Default is False.
178182
synapse_client: Optionally provide a Synapse client.
179183
Returns:
180-
The URL that can be used to download a file for a given WikiPage file attachment.
184+
If download_file is True, the attachment file will be downloaded to the download_location. Otherwise, the URL will be returned.
181185
"""
182186
return ""
183187

184-
def get_attachment_preview_url(
188+
def get_attachment_preview(
185189
self,
186190
file_name: str,
187191
*,
188192
wiki_version: Optional[int] = None,
189193
redirect: Optional[bool] = False,
190194
synapse_client: Optional["Synapse"] = None,
191-
) -> dict:
195+
) -> Union[str, None]:
192196
"""
193-
Get the preview URL of a wiki page attachment asynchronously.
197+
Download the wiki page attachment preview to a local file or return the URL.
194198
Arguments:
195199
file_name: The name of the file to get.
196200
wiki_version: Optional version of the wiki page. If not provided, uses self.wiki_version.
197201
redirect: When set to false, the URL will be returned as text/plain instead of redirecting. Default is False.
198202
synapse_client: Optionally provide a Synapse client.
199203
Returns:
200-
The URL that can be used to download a preview file for a given WikiPage file attachment.
204+
If download_file is True, the attachment preview file will be downloaded to the download_location. Otherwise, the URL will be returned.
201205
"""
202206
return ""
203207

204-
def get_markdown_url_async(
208+
def get_markdown(
205209
self,
206210
*,
207211
redirect: Optional[bool] = False,
208212
synapse_client: Optional["Synapse"] = None,
209-
) -> dict:
213+
) -> Union[str, None]:
210214
"""
211-
Get the markdown URL of this wiki page asynchronously.
215+
Download the markdown file to a local file or return the URL.
212216
Arguments:
213217
redirect: When set to false, the URL will be returned as text/plain instead of redirecting. Default is False.
214218
synapse_client: Optionally provide a Synapse client.
215219
Returns:
216-
The URL that can be used to download the markdown file for this WikiPage.
220+
If download_file is True, the markdown file will be downloaded to the download_location. Otherwise, the URL will be returned.
217221
"""
218222
return ""

0 commit comments

Comments
 (0)