Skip to content

Commit c4d2d8f

Browse files
committed
fix formatting issues
1 parent 220ccbf commit c4d2d8f

12 files changed

Lines changed: 933 additions & 471 deletions

synapseclient/api/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,16 @@
131131
update_organization_acl,
132132
validate_entity_with_json_schema,
133133
)
134-
from .storage_location_services import (
134+
from .project_setting_services import (
135135
create_project_setting,
136-
create_storage_location_setting,
137136
delete_project_setting,
138137
get_project_setting,
139-
get_storage_location_setting,
140138
update_project_setting,
141139
)
140+
from .storage_location_services import (
141+
create_storage_location_setting,
142+
get_storage_location_setting,
143+
)
142144
from .table_services import (
143145
ViewEntityType,
144146
ViewTypeMask,
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
"""Services for interacting with project settings in Synapse.
2+
3+
This module provides async REST wrappers for creating, retrieving, updating,
4+
and deleting project settings.
5+
"""
6+
7+
import json
8+
from typing import TYPE_CHECKING, Any, Dict, Optional
9+
10+
if TYPE_CHECKING:
11+
from synapseclient import Synapse
12+
13+
14+
async def get_project_setting(
15+
project_id: str,
16+
setting_type: str = "upload",
17+
*,
18+
synapse_client: Optional["Synapse"] = None,
19+
) -> Optional[Dict[str, Any]]:
20+
"""Retrieve the project setting of a particular setting type for the project or folder.
21+
Only users with READ access on a project can retrieve its project settings.
22+
23+
Arguments:
24+
project_id: The Synapse ID of the project or folder.
25+
setting_type: The type of project setting to retrieve. Currently supports 'upload' only.
26+
synapse_client: If not passed in and caching was not disabled by
27+
`Synapse.allow_client_caching(False)` this will use the last created
28+
instance from the Synapse class constructor.
29+
30+
Returns:
31+
The upload destination list setting matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/project/UploadDestinationListSetting.html>.
32+
If the storage location is Synapse S3, the response will be an empty string.
33+
"""
34+
from synapseclient import Synapse
35+
36+
client = Synapse.get_client(synapse_client=synapse_client)
37+
response = await client.rest_get_async(
38+
uri=f"/projectSettings/{project_id}/type/{setting_type}",
39+
)
40+
return response
41+
42+
43+
async def create_project_setting(
44+
request: Dict[str, Any],
45+
*,
46+
synapse_client: Optional["Synapse"] = None,
47+
) -> Dict[str, Any]:
48+
"""Create a project setting for a project or folder.
49+
Only the users with CREATE access to the project or folder can add a project setting.
50+
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>.
51+
A project can have a maximum of 10 storage locations.
52+
53+
Arguments:
54+
request: The project setting request body matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/project/ProjectSetting.html>.
55+
synapse_client: If not passed in and caching was not disabled by
56+
`Synapse.allow_client_caching(False)` this will use the last created
57+
instance from the Synapse class constructor.
58+
59+
Returns:
60+
The created project setting matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/project/ProjectSetting.html>.
61+
"""
62+
from synapseclient import Synapse
63+
64+
client = Synapse.get_client(synapse_client=synapse_client)
65+
return await client.rest_post_async(
66+
uri="/projectSettings",
67+
body=json.dumps(request),
68+
)
69+
70+
71+
async def update_project_setting(
72+
request: Dict[str, Any],
73+
*,
74+
synapse_client: Optional["Synapse"] = None,
75+
) -> None:
76+
"""Update an existing project setting for a project or folder.
77+
Only the users with UPDATE access to the project or folder can update a project setting.
78+
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>.
79+
A project can have a maximum of 10 storage locations.
80+
81+
Arguments:
82+
request: The project setting request body including the id field matching <https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/project/ProjectSetting.html>.
83+
synapse_client: If not passed in and caching was not disabled by
84+
`Synapse.allow_client_caching(False)` this will use the last created
85+
instance from the Synapse class constructor.
86+
87+
Returns:
88+
None
89+
"""
90+
from synapseclient import Synapse
91+
92+
client = Synapse.get_client(synapse_client=synapse_client)
93+
return await client.rest_put_async(
94+
uri="/projectSettings",
95+
body=json.dumps(request),
96+
)
97+
98+
99+
async def delete_project_setting(
100+
setting_id: str,
101+
*,
102+
synapse_client: Optional["Synapse"] = None,
103+
) -> None:
104+
"""Delete a project setting for a project or folder.
105+
Only the users with DELETE access to the project or folder can delete a project setting.
106+
107+
Arguments:
108+
setting_id: The ID of the project setting to delete.
109+
synapse_client: If not passed in and caching was not disabled by
110+
`Synapse.allow_client_caching(False)` this will use the last created
111+
instance from the Synapse class constructor.
112+
113+
Returns:
114+
None
115+
"""
116+
from synapseclient import Synapse
117+
118+
client = Synapse.get_client(synapse_client=synapse_client)
119+
await client.rest_delete_async(
120+
uri=f"/projectSettings/{setting_id}",
121+
)
Lines changed: 3 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
"""Services for interacting with storage location settings and project settings in Synapse.
1+
"""Services for interacting with storage location settings in Synapse.
22
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.
55
"""
66

77
import json
@@ -64,115 +64,3 @@ async def get_storage_location_setting(
6464
return await client.rest_get_async(
6565
uri=f"/storageLocation/{storage_location_id}",
6666
)
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-
)

synapseclient/models/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from synapseclient.models.materializedview import MaterializedView
2525
from synapseclient.models.mixins.table_components import QueryMixin
2626
from synapseclient.models.project import Project
27+
from synapseclient.models.project_setting import ProjectSetting
2728
from synapseclient.models.recordset import RecordSet
2829
from synapseclient.models.schema_organization import JSONSchema, SchemaOrganization
2930
from synapseclient.models.services import FailureStrategy
@@ -164,6 +165,8 @@
164165
"StorageLocation",
165166
"StorageLocationType",
166167
"UploadType",
168+
# Project Setting models
169+
"ProjectSetting",
167170
]
168171

169172
# Static methods to expose as functions

synapseclient/models/folder.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
from synapseclient.models.mixins import (
1717
AccessControllable,
1818
ContainerEntityJSONSchema,
19+
ProjectSettingsMixin,
1920
StorableContainer,
2021
)
21-
from synapseclient.models.mixins.storage_location_mixin import (
22-
StorageLocationConfigurable,
23-
)
2422
from synapseclient.models.protocols.folder_protocol import FolderSynchronousProtocol
2523
from synapseclient.models.services.search import get_id
2624
from synapseclient.models.services.storable_entity import store_entity
@@ -50,7 +48,7 @@ class Folder(
5048
AccessControllable,
5149
StorableContainer,
5250
ContainerEntityJSONSchema,
53-
StorageLocationConfigurable,
51+
ProjectSettingsMixin,
5452
):
5553
"""Folder is a hierarchical container for organizing data in Synapse.
5654

synapseclient/models/mixins/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@
2323
)
2424
from synapseclient.models.mixins.storable_container import StorableContainer
2525
from synapseclient.models.mixins.storage_location_mixin import (
26+
ProjectSettingsMixin,
2627
StorageLocationConfigurable,
2728
)
2829

2930
__all__ = [
3031
"AccessControllable",
3132
"EnumCoercionMixin",
33+
"ProjectSettingsMixin",
3234
"StorableContainer",
3335
"StorageLocationConfigurable",
3436
"AsynchronousCommunicator",

0 commit comments

Comments
 (0)