|
1 | | -"""Services for interacting with storage location settings and project settings in Synapse. |
| 1 | +"""Services for interacting with storage location settings in Synapse. |
2 | 2 |
|
3 | | -This module provides async REST wrappers for creating, retrieving, and managing |
4 | | -storage location settings and their associated project settings. |
| 3 | +This module provides async REST wrappers for creating and retrieving |
| 4 | +storage location settings. |
5 | 5 | """ |
6 | 6 |
|
7 | 7 | import json |
@@ -64,115 +64,3 @@ async def get_storage_location_setting( |
64 | 64 | return await client.rest_get_async( |
65 | 65 | uri=f"/storageLocation/{storage_location_id}", |
66 | 66 | ) |
67 | | - |
68 | | - |
69 | | -async def get_project_setting( |
70 | | - project_id: str, |
71 | | - setting_type: str = "upload", |
72 | | - *, |
73 | | - synapse_client: Optional["Synapse"] = None, |
74 | | -) -> Optional[Dict[str, Any]]: |
75 | | - """Retrieve the project setting of a particular setting type for the project or folder. |
76 | | - Only users with READ access on a project can retrieve its project settings. |
77 | | -
|
78 | | - Arguments: |
79 | | - project_id: The Synapse ID of the project or folder. |
80 | | - setting_type: The type of project setting to retrieve. Currently supports 'upload' only. |
81 | | - synapse_client: If not passed in and caching was not disabled by |
82 | | - `Synapse.allow_client_caching(False)` this will use the last created |
83 | | - instance from the Synapse class constructor. |
84 | | -
|
85 | | - Returns: |
86 | | - The upload destination list setting matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/project/UploadDestinationListSetting.html>. |
87 | | - If the storage location is Synapse S3, the response will be None. |
88 | | - """ |
89 | | - from synapseclient import Synapse |
90 | | - |
91 | | - client = Synapse.get_client(synapse_client=synapse_client) |
92 | | - response = await client.rest_get_async( |
93 | | - uri=f"/projectSettings/{project_id}/type/{setting_type}", |
94 | | - ) |
95 | | - return ( |
96 | | - response if response else None |
97 | | - ) # if no project setting, a empty string is returned as the response |
98 | | - |
99 | | - |
100 | | -async def create_project_setting( |
101 | | - request: Dict[str, Any], |
102 | | - *, |
103 | | - synapse_client: Optional["Synapse"] = None, |
104 | | -) -> Dict[str, Any]: |
105 | | - """Create a project setting for a project or folder. |
106 | | - Only the users with CREATE access to the project or folder can add a project setting. |
107 | | - Currently, only the "upload" project setting is supported. This is implemented using UploadDestinationListSetting matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/project/UploadDestinationListSetting.html>. |
108 | | - A project can have a maximum of 10 storage locations. |
109 | | -
|
110 | | - Arguments: |
111 | | - request: The project setting request body matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/project/ProjectSetting.html>. |
112 | | - synapse_client: If not passed in and caching was not disabled by |
113 | | - `Synapse.allow_client_caching(False)` this will use the last created |
114 | | - instance from the Synapse class constructor. |
115 | | -
|
116 | | - Returns: |
117 | | - The created project setting matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/project/ProjectSetting.html>. |
118 | | - """ |
119 | | - from synapseclient import Synapse |
120 | | - |
121 | | - client = Synapse.get_client(synapse_client=synapse_client) |
122 | | - return await client.rest_post_async( |
123 | | - uri="/projectSettings", |
124 | | - body=json.dumps(request), |
125 | | - ) |
126 | | - |
127 | | - |
128 | | -async def update_project_setting( |
129 | | - request: Dict[str, Any], |
130 | | - *, |
131 | | - synapse_client: Optional["Synapse"] = None, |
132 | | -) -> None: |
133 | | - """Update an existing project setting for a project or folder. |
134 | | - Only the users with UPDATE access to the project or folder can update a project setting. |
135 | | - Currently, only the "upload" project setting is supported. This is implemented using UploadDestinationListSetting matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/project/UploadDestinationListSetting.html>. |
136 | | - A project can have a maximum of 10 storage locations. |
137 | | -
|
138 | | - Arguments: |
139 | | - request: The project setting request body including the id field matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/project/ProjectSetting.html>. |
140 | | - synapse_client: If not passed in and caching was not disabled by |
141 | | - `Synapse.allow_client_caching(False)` this will use the last created |
142 | | - instance from the Synapse class constructor. |
143 | | -
|
144 | | - Returns: |
145 | | - None |
146 | | - """ |
147 | | - from synapseclient import Synapse |
148 | | - |
149 | | - client = Synapse.get_client(synapse_client=synapse_client) |
150 | | - return await client.rest_put_async( |
151 | | - uri="/projectSettings", |
152 | | - body=json.dumps(request), |
153 | | - ) |
154 | | - |
155 | | - |
156 | | -async def delete_project_setting( |
157 | | - project_setting_id: str, |
158 | | - *, |
159 | | - synapse_client: Optional["Synapse"] = None, |
160 | | -) -> None: |
161 | | - """Delete a project setting for a project or folder. |
162 | | - Only the users with DELETE access to the project or folder can delete a project setting. |
163 | | -
|
164 | | - Arguments: |
165 | | - project_setting_id: The ID of the project setting to delete. |
166 | | - synapse_client: If not passed in and caching was not disabled by |
167 | | - `Synapse.allow_client_caching(False)` this will use the last created |
168 | | - instance from the Synapse class constructor. |
169 | | -
|
170 | | - Returns: |
171 | | - None |
172 | | - """ |
173 | | - from synapseclient import Synapse |
174 | | - |
175 | | - client = Synapse.get_client(synapse_client=synapse_client) |
176 | | - await client.rest_delete_async( |
177 | | - uri=f"/projectSettings/{project_setting_id}", |
178 | | - ) |
0 commit comments