Rest APIs¶
This section is for super users / developers only. These functions are subject to change as they are internal development functions. Use at your own risk.
The functions provided in these documents are generally direct representations of the Synapse REST API. They're used within the Synapse Python Client to interact with the Synapse servers. These will eventually be removed from the Synapse Python Client in favor of an auto-generated client derived from the Synapse Open API Spec.
synapseclient.api.agent_services
¶
This module is responsible for exposing the services defined at: https://rest-docs.synapse.org/rest/#org.sagebionetworks.repo.web.controller.AgentController
Classes¶
Functions¶
register_agent
async
¶
register_agent(cloud_agent_id: str, cloud_alias_id: Optional[str] = None, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Any]
Registers an agent with Synapse OR gets existing agent registration. Sends a request matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/agent/AgentRegistrationRequest.html
| PARAMETER | DESCRIPTION |
|---|---|
cloud_agent_id
|
The cloud provider ID of the agent to register.
TYPE:
|
cloud_alias_id
|
The cloud provider alias ID of the agent to register. In the Synapse API, this defaults to 'TSTALIASID'. |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
The registered agent matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/agent/AgentRegistration.html |
Source code in synapseclient/api/agent_services.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
get_agent
async
¶
Gets information about an existing agent registration.
| PARAMETER | DESCRIPTION |
|---|---|
registration_id
|
The ID of the agent registration to get.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
The requested agent registration matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/agent/AgentRegistration.html |
Source code in synapseclient/api/agent_services.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
start_session
async
¶
start_session(access_level: str, agent_registration_id: str, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Any]
Starts a new chat session with an agent. Sends a request matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/agent/CreateAgentSessionRequest.html
| PARAMETER | DESCRIPTION |
|---|---|
access_level
|
The access level of the agent.
TYPE:
|
agent_registration_id
|
The ID of the agent registration to start the session for.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
Source code in synapseclient/api/agent_services.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | |
get_session
async
¶
Gets information about an existing chat session.
| PARAMETER | DESCRIPTION |
|---|---|
id
|
The ID of the session to get.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
The requested session matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/agent/AgentSession.html |
Source code in synapseclient/api/agent_services.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
update_session
async
¶
update_session(id: str, access_level: str, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Any]
Updates the access level for a chat session. Sends a request matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/agent/UpdateAgentSessionRequest.html
| PARAMETER | DESCRIPTION |
|---|---|
id
|
The ID of the session to update.
TYPE:
|
access_level
|
The access level of the agent.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
Source code in synapseclient/api/agent_services.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
get_trace
async
¶
get_trace(prompt_id: str, *, newer_than: Optional[int] = None, synapse_client: Optional[Synapse] = None) -> Dict[str, Any]
Gets the trace of a prompt. Sends a request matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/agent/TraceEventsRequest.html
| PARAMETER | DESCRIPTION |
|---|---|
prompt_id
|
The token of the prompt to get the trace for.
TYPE:
|
newer_than
|
The timestamp to get trace results newer than. Defaults to None (all results). Timestamps should be in milliseconds since the epoch per the API documentation. https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/agent/TraceEvent.html |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
Source code in synapseclient/api/agent_services.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
synapseclient.api.annotations
¶
The purpose of this module is to provide any functions that are needed to interact with annotations that are not cleanly provided by the synapseclient library.
Classes¶
Functions¶
set_annotations
¶
Call to synapse and set the annotations for the given input.
| PARAMETER | DESCRIPTION |
|---|---|
annotations
|
The annotations to set. This is expected to have the id, etag, and annotations filled in.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
Returns: The annotations set in Synapse.
Source code in synapseclient/api/annotations.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
set_annotations_async
async
¶
Call to synapse and set the annotations for the given input.
| PARAMETER | DESCRIPTION |
|---|---|
annotations
|
The annotations to set. This is expected to have the id, etag, and annotations filled in.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
Returns: The annotations set in Synapse.
Source code in synapseclient/api/annotations.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
synapseclient.api.api_client
¶
Classes¶
Functions¶
rest_post_paginated_async
async
¶
rest_post_paginated_async(uri: str, body: Optional[Dict[str, Any]] = None, endpoint: Optional[str] = None, headers: Optional[Headers] = None, retry_policy: Optional[Dict[str, Any]] = None, requests_session_async_synapse: Optional[AsyncClient] = None, *, synapse_client: Optional[Synapse] = None, **kwargs) -> AsyncGenerator[Dict[str, str], None]
Asynchronously yield items from a paginated POST endpoint.
| PARAMETER | DESCRIPTION |
|---|---|
uri
|
Endpoint URI for the POST request.
TYPE:
|
body
|
Request payload dictionary. |
endpoint
|
Optional server endpoint override. |
headers
|
Optional HTTP headers.
TYPE:
|
retry_policy
|
Optional retry settings. |
requests_session_async_synapse
|
Optional async HTTPX client session.
TYPE:
|
kwargs
|
Additional keyword arguments for the request.
DEFAULT:
|
synapse_client
|
Optional Synapse client instance for authentication. |
Yields: Individual items from each page of the response.
Source code in synapseclient/api/api_client.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
rest_get_paginated_async
async
¶
rest_get_paginated_async(uri: str, limit: int = 20, offset: int = 0, endpoint: Optional[str] = None, headers: Optional[Headers] = None, retry_policy: Optional[Dict[str, Any]] = None, requests_session_async_synapse: Optional[AsyncClient] = None, *, synapse_client: Optional[Synapse] = None, **kwargs) -> AsyncGenerator[Dict[str, str], None]
Asynchronously yield items from a paginated GET endpoint.
| PARAMETER | DESCRIPTION |
|---|---|
uri
|
Endpoint URI for the GET request.
TYPE:
|
limit
|
How many records should be returned per request
TYPE:
|
offset
|
At what record offset from the first should iteration start
TYPE:
|
endpoint
|
Optional server endpoint override. |
headers
|
Optional HTTP headers.
TYPE:
|
retry_policy
|
Optional retry settings. |
requests_session_async_synapse
|
Optional async HTTPX client session.
TYPE:
|
kwargs
|
Additional keyword arguments for the request.
DEFAULT:
|
synapse_client
|
Optional Synapse client instance for authentication. |
Yields: Individual items from each page of the response.
The limit parameter is set at 20 by default. Using a larger limit results in fewer calls to the service, but if responses are large enough to be a burden on the service they may be truncated.
Source code in synapseclient/api/api_client.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
synapseclient.api.configuration_services
¶
This module is responsible for exposing access to any configuration either through file, environment variables, or other means.
Functions¶
get_config_file
cached
¶
get_config_file(config_path: str) -> RawConfigParser
Retrieves the client configuration information.
| PARAMETER | DESCRIPTION |
|---|---|
config_path
|
Path to configuration file on local file system
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
RawConfigParser
|
A RawConfigParser populated with properties from the user's configuration file. |
Source code in synapseclient/api/configuration_services.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
get_config_section_dict
¶
Get a profile section in the configuration file with the section name.
| PARAMETER | DESCRIPTION |
|---|---|
section_name
|
The name of the profile section in the configuration file
TYPE:
|
config_path
|
Path to configuration file on local file system
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, str]
|
A dictionary containing the configuration profile section content. If the |
Dict[str, str]
|
section does not exist, an empty dictionary is returned. |
Source code in synapseclient/api/configuration_services.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
get_client_authenticated_s3_profile
¶
Get the authenticated S3 profile from the configuration file.
| PARAMETER | DESCRIPTION |
|---|---|
endpoint
|
The location of the target service
TYPE:
|
bucket
|
AWS S3 bucket name
TYPE:
|
config_path
|
Path to configuration file on local file system
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, str]
|
The authenticated S3 profile |
Source code in synapseclient/api/configuration_services.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
get_config_authentication
¶
Get the authentication section of the configuration file.
| PARAMETER | DESCRIPTION |
|---|---|
config_path
|
Path to configuration file on local file system
TYPE:
|
profile
|
The profile name to retrieve credentials for. Defaults to "default".
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, str]
|
The authentication section of the configuration file |
Source code in synapseclient/api/configuration_services.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
get_transfer_config
¶
Get the transfer profile from the configuration file.
| PARAMETER | DESCRIPTION |
|---|---|
config_path
|
Path to configuration file on local file system
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
Invalid max_threads value. Should be equal or less than 16. |
ValueError
|
Invalid use_boto_sts value. Should be true or false. |
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, str]
|
The transfer profile |
Source code in synapseclient/api/configuration_services.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
synapseclient.api.entity_bundle_services_v2
¶
This module is responsible for exposing the services defined at: https://rest-docs.synapse.org/rest/#org.sagebionetworks.repo.web.controller.EntityBundleV2Controller
Classes¶
Functions¶
get_entity_id_bundle2
async
¶
get_entity_id_bundle2(entity_id: str, request: Optional[Dict[str, bool]] = None, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Any]
| PARAMETER | DESCRIPTION |
|---|---|
entity_id
|
The ID of the entity to which the bundle belongs
TYPE:
|
request
|
The request for the bundle matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/entitybundle/v2/EntityBundleRequest.html. If not passed in or None, the default request will be used:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
The requested entity bundle matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/entitybundle/v2/EntityBundle.html |
Source code in synapseclient/api/entity_bundle_services_v2.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
get_entity_id_version_bundle2
async
¶
get_entity_id_version_bundle2(entity_id: str, version: int, request: Optional[Dict[str, bool]] = None, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Any]
| PARAMETER | DESCRIPTION |
|---|---|
entity_id
|
The ID of the entity to which the bundle belongs
TYPE:
|
version
|
The version of the entity to which the bundle belongs
TYPE:
|
request
|
The request for the bundle matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/entitybundle/v2/EntityBundleRequest.html. If not passed in or None, the default request will be used:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
The requested entity bundle matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/entitybundle/v2/EntityBundle.html |
Source code in synapseclient/api/entity_bundle_services_v2.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
post_entity_bundle2_create
async
¶
post_entity_bundle2_create(request: Dict[str, Any], generated_by: Optional[str] = None, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Any]
| PARAMETER | DESCRIPTION |
|---|---|
request
|
The request for the bundle matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/entitybundle/v2/EntityBundleCreate.html |
generated_by
|
The ID of the activity to associate with the entity. |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
The requested entity bundle matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/entitybundle/v2/EntityBundle.html |
Source code in synapseclient/api/entity_bundle_services_v2.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
put_entity_id_bundle2
async
¶
put_entity_id_bundle2(entity_id: str, request: Dict[str, Any], generated_by: Optional[str] = None, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Any]
| PARAMETER | DESCRIPTION |
|---|---|
entity_id
|
The ID of the entity to which the bundle belongs.
TYPE:
|
request
|
The request for the bundle matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/entitybundle/v2/EntityBundleCreate.html |
generated_by
|
The ID of the activity to associate with the entity. |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
The requested entity bundle matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/entitybundle/v2/EntityBundle.html |
Source code in synapseclient/api/entity_bundle_services_v2.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
synapseclient.api.entity_factory
¶
Factory type functions to create and retrieve entities from Synapse
Classes¶
Functions¶
get_from_entity_factory
async
¶
get_from_entity_factory(synapse_id_or_path: str, version: int = None, if_collision: str = 'keep.both', limit_search: str = None, md5: str = None, download_file: bool = True, download_location: str = None, follow_link: bool = False, entity_to_update: Union[Project, File, Folder, Table, Dataset, EntityView] = None, *, synapse_client: Optional[Synapse] = None) -> Union[Project, File, Folder]
Factory type function to retrieve an entity from Synapse. Optionally you may also
pass in entity_to_update if you want to update the fields on the existing entity
instead of creating a new instance.
| PARAMETER | DESCRIPTION |
|---|---|
synapse_id_or_path
|
The Synapse ID or file path of the entity to retrieve.
TYPE:
|
version
|
The version number of the entity to retrieve.
TYPE:
|
if_collision
|
Determines how to handle file collisions. May be:
TYPE:
|
limit_search
|
Limit the search to a specific project or folder. Only used
if
TYPE:
|
md5
|
The MD5 of the file to retrieve. If not passed in, the MD5 will be
calculated. Only used if
TYPE:
|
download_file
|
Whether associated files should be downloaded.
TYPE:
|
download_location
|
The directory to download the file to.
TYPE:
|
follow_link
|
Whether to follow a link to its target. This will only do a single hop to the target of the link.
TYPE:
|
entity_to_update
|
An existing entity class instance to update with data from Synapse.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
Example
|
Using this function Download file into cache
Download file into current working directory
|
| RAISES | DESCRIPTION |
|---|---|
SynapseFileNotFoundError
|
If the id is not a synapse ID and it is not a valid file path. |
Source code in synapseclient/api/entity_factory.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
synapseclient.api.entity_services
¶
This module is responsible for exposing the services defined at: https://rest-docs.synapse.org/rest/#org.sagebionetworks.repo.web.controller.EntityController
Classes¶
EntityHeader
dataclass
¶
JSON schema for EntityHeader POJO. This represents metadata about a Synapse entity.
| ATTRIBUTE | DESCRIPTION |
|---|---|
name |
The name of the entity |
id |
The id of the entity |
type |
The type of the entity |
version_number |
The version number of the entity |
version_label |
The user defined version label of the entity |
is_latest_version |
If this version is the latest version of the entity |
benefactor_id |
The ID of the entity that this Entity's ACL is inherited from |
created_on |
The date this entity was created |
modified_on |
The date this entity was last modified |
created_by |
The ID of the user that created this entity |
modified_by |
The ID of the user that last modified this entity |
Source code in synapseclient/api/entity_services.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
Attributes¶
version_number
class-attribute
instance-attribute
¶
The version number of the entity
version_label
class-attribute
instance-attribute
¶
The user defined version label of the entity
is_latest_version
class-attribute
instance-attribute
¶
If this version is the latest version of the entity
benefactor_id
class-attribute
instance-attribute
¶
The ID of the entity that this Entity's ACL is inherited from
created_on
class-attribute
instance-attribute
¶
The date this entity was created
modified_on
class-attribute
instance-attribute
¶
The date this entity was last modified
created_by
class-attribute
instance-attribute
¶
The ID of the user that created this entity
modified_by
class-attribute
instance-attribute
¶
The ID of the user that last modified this entity
Functions¶
fill_from_dict
¶
fill_from_dict(synapse_response: Dict[str, Any]) -> EntityHeader
Converts a response from the REST API into this dataclass.
Source code in synapseclient/api/entity_services.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
Functions¶
post_entity
async
¶
post_entity(request: Dict[str, Any], generated_by: Optional[str] = None, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Any]
| PARAMETER | DESCRIPTION |
|---|---|
request
|
The request for the entity matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/Entity.html |
generated_by
|
The ID of the activity to associate with the entity. |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
The requested entity matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/Entity.html |
Source code in synapseclient/api/entity_services.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
put_entity
async
¶
put_entity(entity_id: str, request: Dict[str, Any], new_version: bool = False, generated_by: Optional[str] = None, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Any]
| PARAMETER | DESCRIPTION |
|---|---|
entity_id
|
The ID of the entity to update.
TYPE:
|
request
|
The request for the entity matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/Entity.html |
new_version
|
If true, a new version of the entity will be created.
TYPE:
|
generated_by
|
The ID of the activity to associate with the entity. |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
The requested entity bundle matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/Entity.html |
Source code in synapseclient/api/entity_services.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
get_entity
async
¶
get_entity(entity_id: str, version_number: int = None, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Any]
| PARAMETER | DESCRIPTION |
|---|---|
entity_id
|
The ID of the entity.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
The requested entity bundle matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/Entity.html |
Source code in synapseclient/api/entity_services.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
get_upload_destination
async
¶
get_upload_destination(entity_id: str, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Union[str, int]]
https://rest-docs.synapse.org/rest/GET/entity/id/uploadDestination.html
| PARAMETER | DESCRIPTION |
|---|---|
entity_id
|
The ID of the entity.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Union[str, int]]
|
The upload destination. |
Dict[str, Union[str, int]]
|
Source code in synapseclient/api/entity_services.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
get_upload_destination_location
async
¶
get_upload_destination_location(entity_id: str, location: str, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Union[str, int]]
https://rest-docs.synapse.org/rest/GET/entity/id/uploadDestination/storageLocationId.html
| PARAMETER | DESCRIPTION |
|---|---|
entity_id
|
The ID of the entity.
TYPE:
|
location
|
A storage location ID of the upload destination.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Union[str, int]]
|
The upload destination. |
Dict[str, Union[str, int]]
|
Source code in synapseclient/api/entity_services.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
create_access_requirements_if_none
async
¶
create_access_requirements_if_none(entity_id: str, *, synapse_client: Optional[Synapse] = None) -> None
Checks to see if the given entity has access requirements. If not, then one is added
| PARAMETER | DESCRIPTION |
|---|---|
entity_id
|
The ID of the entity.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
Source code in synapseclient/api/entity_services.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
delete_entity_generated_by
async
¶
| PARAMETER | DESCRIPTION |
|---|---|
entity_id
|
The ID of the entity.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
Returns: None
Source code in synapseclient/api/entity_services.py
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | |
delete_entity
async
¶
delete_entity(entity_id: str, version_number: int = None, *, synapse_client: Optional[Synapse] = None) -> None
Deletes an entity from Synapse.
| PARAMETER | DESCRIPTION |
|---|---|
entity_id
|
The ID of the entity. This may include version
TYPE:
|
version_number
|
The version number of the entity to delete.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
Delete the entity syn123:
This will delete all versions of the entity.
import asyncio
from synapseclient import Synapse
from synapseclient.api import delete_entity
syn = Synapse()
syn.login()
async def main():
await delete_entity(entity_id="syn123")
asyncio.run(main())
Delete a specific version of the entity syn123:
This will delete version 3 of the entity.
import asyncio
from synapseclient import Synapse
from synapseclient.api import delete_entity
syn = Synapse()
syn.login()
async def main():
await delete_entity(entity_id="syn123", version_number=3)
asyncio.run(main())
Returns: None
Source code in synapseclient/api/entity_services.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | |
delete_entity_acl
async
¶
Delete the Access Control List (ACL) for a given Entity.
By default, Entities such as FileEntity and Folder inherit their permission from their containing Project. For such Entities the Project is the Entity's 'benefactor'. This permission inheritance can be overridden by creating an ACL for the Entity. When this occurs the Entity becomes its own benefactor and all permission are determined by its own ACL.
If the ACL of an Entity is deleted, then its benefactor will automatically be set to its parent's benefactor. The ACL for a Project cannot be deleted.
Note: The caller must be granted ACCESS_TYPE.CHANGE_PERMISSIONS on the Entity to call this method.
| PARAMETER | DESCRIPTION |
|---|---|
entity_id
|
The ID of the entity that should have its ACL deleted.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
Delete the ACL for entity syn123:
This will delete the ACL for the entity, making it inherit permissions from its parent.
import asyncio
from synapseclient import Synapse
from synapseclient.api import delete_entity_acl
syn = Synapse()
syn.login()
async def main():
await delete_entity_acl(entity_id="syn123")
asyncio.run(main())
Returns: None
Source code in synapseclient/api/entity_services.py
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | |
get_entity_acl
async
¶
get_entity_acl(entity_id: str, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Union[str, List[Dict[str, Union[int, List[str]]]]]]
Get the Access Control List (ACL) for an entity.
Note: If this method is called on an Entity that is inheriting its permission from another Entity a NOT_FOUND (404) response will be generated. The error response message will include the Entity's benefactor ID.
| PARAMETER | DESCRIPTION |
|---|---|
entity_id
|
The ID of the entity.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
Source code in synapseclient/api/entity_services.py
419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | |
get_entity_benefactor
async
¶
get_entity_benefactor(entity_id: str, *, synapse_client: Optional[Synapse] = None) -> EntityHeader
Get an Entity's benefactor. An Entity gets its ACL from its benefactor.
Implements: https://rest-docs.synapse.org/rest/GET/entity/id/benefactor.html
| PARAMETER | DESCRIPTION |
|---|---|
entity_id
|
The ID of the entity.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
EntityHeader
|
The EntityHeader of the entity's benefactor (the entity from which it inherits its ACL). |
Get the benefactor of an entity
Get the benefactor entity header for entity syn123.
import asyncio
from synapseclient import Synapse
from synapseclient.api import get_entity_benefactor
syn = Synapse()
syn.login()
async def main():
benefactor = await get_entity_benefactor(entity_id="syn123")
print(f"Entity benefactor: {benefactor.name} (ID: {benefactor.id})")
asyncio.run(main())
Source code in synapseclient/api/entity_services.py
445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 | |
get_entity_path
async
¶
get_entity_path(entity_id: str, *, synapse_client: Optional[Synapse] = None) -> Dict[str, List[Dict[str, Union[str, int, bool]]]]
Implements: https://rest-docs.synapse.org/rest/GET/entity/id/path.html
| PARAMETER | DESCRIPTION |
|---|---|
entity_id
|
The ID of the entity.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, List[Dict[str, Union[str, int, bool]]]]
|
Entity paths matching: |
Dict[str, List[Dict[str, Union[str, int, bool]]]]
|
Source code in synapseclient/api/entity_services.py
494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 | |
get_entities_by_md5
async
¶
get_entities_by_md5(md5: str, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Union[int, List[Dict[str, Any]]]]
Implements: https://rest-docs.synapse.org/rest/GET/entity/md5/md5.html
| PARAMETER | DESCRIPTION |
|---|---|
md5
|
The MD5 of the entity.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Union[int, List[Dict[str, Any]]]]
|
Paginated results of: |
Dict[str, Union[int, List[Dict[str, Any]]]]
|
|
Dict[str, Union[int, List[Dict[str, Any]]]]
|
Source code in synapseclient/api/entity_services.py
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 | |
get_entity_provenance
async
¶
get_entity_provenance(entity_id: str, version_number: Optional[int] = None, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Any]
Retrieve provenance information for a Synapse Entity.
| PARAMETER | DESCRIPTION |
|---|---|
entity_id
|
The ID of the entity. This may include version
TYPE:
|
version_number
|
The version of the Entity to retrieve. Gets the most recent version if omitted. |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
Activity object as a dictionary or raises exception if no provenance record exists. |
Get provenance for an entity
Get the provenance information for entity syn123.
import asyncio
from synapseclient import Synapse
from synapseclient.api import get_entity_provenance
syn = Synapse()
syn.login()
async def main():
activity = await get_entity_provenance(entity_id="syn123")
print(f"Activity: {activity}")
asyncio.run(main())
Get provenance for a specific version
Get the provenance information for version 3 of entity syn123.
import asyncio
from synapseclient import Synapse
from synapseclient.api import get_entity_provenance
syn = Synapse()
syn.login()
async def main():
activity = await get_entity_provenance(entity_id="syn123", version_number=3)
print(f"Activity: {activity}")
asyncio.run(main())
Source code in synapseclient/api/entity_services.py
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 | |
set_entity_provenance
async
¶
set_entity_provenance(entity_id: str, activity: Dict[str, Any], *, synapse_client: Optional[Synapse] = None) -> Dict[str, Any]
Stores a record of the code and data used to derive a Synapse entity.
| PARAMETER | DESCRIPTION |
|---|---|
entity_id
|
The ID of the entity.
TYPE:
|
activity
|
A dictionary representing an Activity object. |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
An updated Activity object as a dictionary. |
Set provenance for an entity
Set the provenance for entity syn123 with an activity.
import asyncio
from synapseclient import Synapse
from synapseclient.api import set_entity_provenance, create_activity
syn = Synapse()
syn.login()
async def main():
# First create or get an activity
activity = await create_activity({
"name": "Analysis Step",
"description": "Data processing step"
})
# Set the provenance
updated_activity = await set_entity_provenance(
entity_id="syn123",
activity=activity
)
print(f"Updated activity: {updated_activity}")
asyncio.run(main())
Source code in synapseclient/api/entity_services.py
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 | |
delete_entity_provenance
async
¶
Removes provenance information from an Entity and deletes the associated Activity.
| PARAMETER | DESCRIPTION |
|---|---|
entity_id
|
The ID of the entity.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
Delete provenance for an entity
Delete the provenance for entity syn123.
import asyncio
from synapseclient import Synapse
from synapseclient.api import delete_entity_provenance
syn = Synapse()
syn.login()
async def main():
await delete_entity_provenance(entity_id="syn123")
asyncio.run(main())
Returns: None
Source code in synapseclient/api/entity_services.py
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 | |
create_activity
async
¶
create_activity(activity: Dict[str, Any], *, synapse_client: Optional[Synapse] = None) -> Dict[str, Any]
Create a new Activity in Synapse.
| PARAMETER | DESCRIPTION |
|---|---|
activity
|
A dictionary representing an Activity object. |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
The created Activity object as a dictionary. |
Create a new activity
Create a new activity in Synapse.
import asyncio
from synapseclient import Synapse
from synapseclient.api import create_activity
syn = Synapse()
syn.login()
async def main():
activity = await create_activity({
"name": "Data Analysis",
"description": "Processing raw data"
})
print(f"Created activity: {activity}")
asyncio.run(main())
Source code in synapseclient/api/entity_services.py
735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 | |
update_activity
async
¶
update_activity(activity: Dict[str, Any], *, synapse_client: Optional[Synapse] = None) -> Dict[str, Any]
Modifies an existing Activity.
| PARAMETER | DESCRIPTION |
|---|---|
activity
|
The Activity to be updated. Must contain an 'id' field. |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
An updated Activity object as a dictionary. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the activity does not contain an 'id' field. |
Update an existing activity
Update an existing activity in Synapse.
import asyncio
from synapseclient import Synapse
from synapseclient.api import update_activity
syn = Synapse()
syn.login()
async def main():
activity = {
"id": "12345",
"name": "Updated Analysis",
"description": "Updated processing step"
}
updated_activity = await update_activity(activity)
print(f"Updated activity: {updated_activity}")
asyncio.run(main())
Source code in synapseclient/api/entity_services.py
779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 | |
get_activity
async
¶
Retrieve an Activity by its ID.
| PARAMETER | DESCRIPTION |
|---|---|
activity_id
|
The ID of the activity to retrieve.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
Activity object as a dictionary. |
Get activity by ID
Retrieve an activity using its ID.
import asyncio
from synapseclient import Synapse
from synapseclient.api import get_activity
syn = Synapse()
syn.login()
async def main():
activity = await get_activity(activity_id="12345")
print(f"Activity: {activity}")
asyncio.run(main())
Source code in synapseclient/api/entity_services.py
832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 | |
get_children
async
¶
get_children(parent: Optional[str] = None, include_types: List[str] = None, sort_by: str = 'NAME', sort_direction: str = 'ASC', *, synapse_client: Optional[Synapse] = None) -> AsyncGenerator[Dict[str, Any], None]
Retrieve all entities stored within a parent such as folder or project.
| PARAMETER | DESCRIPTION |
|---|---|
parent
|
The ID of a Synapse container (folder or project) or None to retrieve all projects |
include_types
|
List of entity types to include (e.g., ["folder", "file"]). Available types can be found at: https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/EntityType.html |
sort_by
|
How results should be sorted. Can be "NAME" or "CREATED_ON"
TYPE:
|
sort_direction
|
The direction of the result sort. Can be "ASC" or "DESC"
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| YIELDS | DESCRIPTION |
|---|---|
AsyncGenerator[Dict[str, Any], None]
|
An async generator that yields entity children dictionaries. |
Getting children of a folder
Retrieve all children of a folder:
import asyncio
from synapseclient import Synapse
from synapseclient.api import get_children
syn = Synapse()
syn.login()
async def main():
async for child in get_children(parent="syn123456"):
print(f"Child: {child['name']} (ID: {child['id']})")
asyncio.run(main())
Getting children with specific types
Retrieve only files and folders:
import asyncio
from synapseclient import Synapse
from synapseclient.api import get_children
syn = Synapse()
syn.login()
async def main():
async for child in get_children(
parent="syn123456",
include_types=["file", "folder"],
sort_by="NAME",
sort_direction="ASC"
):
print(f"Child: {child['name']} (Type: {child['type']})")
asyncio.run(main())
Source code in synapseclient/api/entity_services.py
873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 | |
synapseclient.api.file_services
¶
This module is responsible for exposing the services defined at: https://rest-docs.synapse.org/rest/#org.sagebionetworks.repo.web.controller.EntityController
Classes¶
AddPartResponse
dataclass
¶
Result of a part add.
| ATTRIBUTE | DESCRIPTION |
|---|---|
upload_id |
The unique identifier of a multi-part request.
TYPE:
|
part_number |
The part number of the add.
TYPE:
|
add_part_state |
The state of this add.
TYPE:
|
error_message |
If the added failed, this will contain the error message of the cause. Will be None when the add is successful.
TYPE:
|
Source code in synapseclient/api/file_services.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
Functions¶
post_file_multipart
async
¶
post_file_multipart(upload_request_payload: Dict[str, Any], force_restart: bool, endpoint: str, *, synapse_client: Optional[Synapse] = None) -> Dict[str, str]
https://rest-docs.synapse.org/rest/POST/file/multipart.html
| PARAMETER | DESCRIPTION |
|---|---|
upload_request_payload
|
|
force_restart
|
Optional parameter. When True, any upload state for the given file will be cleared and a new upload will be started.
TYPE:
|
endpoint
|
Server endpoint to call to.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, str]
|
The requested multipart upload status matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/file/MultipartUploadStatus.html |
Source code in synapseclient/api/file_services.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
put_file_multipart_add
async
¶
put_file_multipart_add(upload_id: str, part_number: int, md5_hex: str, *, synapse_client: Optional[Synapse] = None) -> AddPartResponse
https://rest-docs.synapse.org/rest/PUT/file/multipart/uploadId/add/partNumber.html
| PARAMETER | DESCRIPTION |
|---|---|
upload_id
|
The unique identifier of the file upload.
TYPE:
|
part_number
|
The part number to add. Must be a number between 1 and 10,000.
TYPE:
|
md5_hex
|
The MD5 of the uploaded part represented as a hexadecimal string. If the provided MD5 does not match the MD5 of the uploaded part, the add will fail.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
AddPartResponse
|
Object matching |
AddPartResponse
|
Source code in synapseclient/api/file_services.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
put_file_multipart_complete
async
¶
put_file_multipart_complete(upload_id: str, endpoint: str, *, synapse_client: Optional[Synapse] = None) -> Dict[str, str]
https://rest-docs.synapse.org/rest/PUT/file/multipart/uploadId/complete.html
| PARAMETER | DESCRIPTION |
|---|---|
upload_id
|
The unique identifier of the file upload.
TYPE:
|
endpoint
|
Server endpoint to call to.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, str]
|
Object matching |
Dict[str, str]
|
Source code in synapseclient/api/file_services.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
post_file_multipart_presigned_urls
async
¶
post_file_multipart_presigned_urls(upload_id: str, part_numbers: List[int], *, synapse_client: Optional[Synapse] = None) -> Dict[str, Any]
https://rest-docs.synapse.org/rest/PUT/file/multipart/uploadId/add/partNumber.html
| PARAMETER | DESCRIPTION |
|---|---|
upload_id
|
The unique identifier of the file upload.
TYPE:
|
part_numbers
|
The part numbers to get pre-signed URLs for. |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Any]
|
Object matching |
Dict[str, Any]
|
Source code in synapseclient/api/file_services.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
post_external_object_store_filehandle
async
¶
post_external_object_store_filehandle(s3_file_key: str, file_path: str, storage_location_id: int, mimetype: str = None, md5: str = None, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Union[str, int]]
Create a new FileHandle representing an external object. https://rest-docs.synapse.org/rest/POST/externalFileHandle.html
| PARAMETER | DESCRIPTION |
|---|---|
s3_file_key
|
S3 key of the uploaded object
TYPE:
|
file_path
|
The local path of the uploaded file
TYPE:
|
storage_location_id
|
The optional storage location descriptor
TYPE:
|
mimetype
|
The Mimetype of the file, if known.
TYPE:
|
md5
|
The file's content MD5, if known.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Union[str, int]]
|
A FileHandle for objects that are stored externally. |
Dict[str, Union[str, int]]
|
Source code in synapseclient/api/file_services.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | |
post_external_filehandle
async
¶
post_external_filehandle(external_url: str, mimetype: str = None, md5: str = None, file_size: int = None, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Union[str, int]]
Create a new FileHandle representing an external object. https://rest-docs.synapse.org/rest/POST/externalFileHandle.html
| PARAMETER | DESCRIPTION |
|---|---|
externalURL
|
An external URL
|
mimetype
|
The Mimetype of the file, if known.
TYPE:
|
md5
|
The file's content MD5.
TYPE:
|
file_size
|
The size of the file in bytes.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Union[str, int]]
|
A FileHandle for objects that are stored externally. |
Dict[str, Union[str, int]]
|
Source code in synapseclient/api/file_services.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
post_external_s3_file_handle
async
¶
post_external_s3_file_handle(bucket_name: str, s3_file_key: str, file_path: str, parent: str = None, storage_location_id: str = None, mimetype: str = None, md5: str = None, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Union[str, int, bool]]
Create an external S3 file handle for e.g. a file that has been uploaded directly to an external S3 storage location.
https://rest-docs.synapse.org/rest/POST/externalFileHandle/s3.html
| PARAMETER | DESCRIPTION |
|---|---|
bucket_name
|
Name of the S3 bucket
TYPE:
|
s3_file_key
|
S3 key of the uploaded object
TYPE:
|
file_path
|
Local path of the uploaded file
TYPE:
|
parent
|
Parent entity to create the file handle in, the file handle will be created in the default storage location of the parent. Mutually exclusive with storage_location_id
TYPE:
|
storage_location_id
|
Explicit storage location id to create the file handle in, mutually exclusive with parent
TYPE:
|
mimetype
|
Mimetype of the file, if known
TYPE:
|
md5
|
MD5 of the file, if known
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Union[str, int, bool]]
|
The created file handle. |
Dict[str, Union[str, int, bool]]
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If neither parent nor storage_location_id is specified, or if both are specified. |
Source code in synapseclient/api/file_services.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | |
get_file_handle
async
¶
get_file_handle(file_handle_id: Dict[str, Union[str, int]], *, synapse_client: Optional[Synapse] = None) -> Dict[str, Union[str, int]]
Retrieve a fileHandle from the fileHandle service. Note: You must be the creator of the filehandle to use this method. Otherwise, an 403-Forbidden error will be raised.
https://rest-docs.synapse.org/rest/GET/fileHandle/handleId.html
| PARAMETER | DESCRIPTION |
|---|---|
file_handle_id
|
The ID of the file handle to look up. |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Union[str, int]]
|
A file handle retrieved from the file handle service. |
Dict[str, Union[str, int]]
|
Source code in synapseclient/api/file_services.py
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | |
get_file_handle_for_download_async
async
¶
get_file_handle_for_download_async(file_handle_id: str, synapse_id: str, entity_type: str = None, *, synapse_client: Optional[Synapse] = None) -> Dict[str, str]
Gets the URL and the metadata as filehandle object for a filehandle or fileHandleId
| PARAMETER | DESCRIPTION |
|---|---|
file_handle_id
|
ID of fileHandle to download
TYPE:
|
synapse_id
|
The ID of the object associated with the file e.g. syn234
TYPE:
|
entity_type
|
Type of object associated with a file e.g. FileEntity, TableEntity https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/file/FileHandleAssociateType.html
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RAISES | DESCRIPTION |
|---|---|
SynapseFileNotFoundError
|
If the fileHandleId is not found in Synapse. |
SynapseError
|
If the user does not have the permission to access the fileHandleId. |
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, str]
|
A dictionary with keys: fileHandle, fileHandleId and preSignedURL |
Source code in synapseclient/api/file_services.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 | |
get_file_handle_for_download
¶
get_file_handle_for_download(file_handle_id: str, synapse_id: str, entity_type: str = None, *, synapse_client: Optional[Synapse] = None) -> Dict[str, str]
Gets the URL and the metadata as filehandle object for a filehandle or fileHandleId
| PARAMETER | DESCRIPTION |
|---|---|
file_handle_id
|
ID of fileHandle to download
TYPE:
|
synapse_id
|
The ID of the object associated with the file e.g. syn234
TYPE:
|
entity_type
|
Type of object associated with a file e.g. FileEntity, TableEntity https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/file/FileHandleAssociateType.html
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RAISES | DESCRIPTION |
|---|---|
SynapseFileNotFoundError
|
If the fileHandleId is not found in Synapse. |
SynapseError
|
If the user does not have the permission to access the fileHandleId. |
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, str]
|
A dictionary with keys: fileHandle, fileHandleId and preSignedURL |
Source code in synapseclient/api/file_services.py
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | |
synapseclient.api.json_schema_services
¶
Classes¶
Functions¶
bind_json_schema_to_entity
async
¶
bind_json_schema_to_entity(synapse_id: str, json_schema_uri: str, *, enable_derived_annotations: bool = False, synapse_client: Optional[Synapse] = None) -> Union[Dict[str, Any], str]
https://rest-docs.synapse.org/rest/PUT/entity/id/schema/binding.html
Bind a JSON schema to an entity
| PARAMETER | DESCRIPTION |
|---|---|
synapse_id
|
Synapse Entity or Synapse Id
TYPE:
|
json_schema_uri
|
JSON schema URI
TYPE:
|
enable_derived_annotations
|
If True, derived annotations will be enabled for this entity
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
Returns: Object matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/schema/JsonSchemaObjectBinding.html
Source code in synapseclient/api/json_schema_services.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
get_json_schema_from_entity
async
¶
get_json_schema_from_entity(synapse_id: str, *, synapse_client: Optional[Synapse] = None) -> Union[Dict[str, Any], str]
https://rest-docs.synapse.org/rest/GET/entity/id/schema/binding.html
Get bound schema from entity
| PARAMETER | DESCRIPTION |
|---|---|
synapse_id
|
Synapse Id
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Union[Dict[str, Any], str]
|
Source code in synapseclient/api/json_schema_services.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
delete_json_schema_from_entity
async
¶
delete_json_schema_from_entity(synapse_id: str, *, synapse_client: Optional[Synapse] = None) -> None
https://rest-docs.synapse.org/rest/DELETE/entity/id/schema/binding.html
Delete bound schema from entity
| PARAMETER | DESCRIPTION |
|---|---|
synapse_id
|
Synapse Id
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
Source code in synapseclient/api/json_schema_services.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 | |
validate_entity_with_json_schema
async
¶
validate_entity_with_json_schema(synapse_id: str, *, synapse_client: Optional[Synapse] = None) -> Union[Dict[str, Union[str, bool]], str]
https://rest-docs.synapse.org/rest/GET/entity/id/schema/validation.html
Get validation results of an entity against bound JSON schema
| PARAMETER | DESCRIPTION |
|---|---|
synapse_id
|
Synapse Id
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
Returns: Object matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/schema/ValidationResults.html
Source code in synapseclient/api/json_schema_services.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
get_json_schema_validation_statistics
async
¶
get_json_schema_validation_statistics(synapse_id: str, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Union[str, int]]
https://rest-docs.synapse.org/rest/GET/entity/id/schema/validation/statistics.html
Get the summary statistic of json schema validation results for
a container entity
Arguments:
synapse_id: Synapse Id
synapse_client: If not passed in and caching was not disabled by
Synapse.allow_client_caching(False) this will use the last created
instance from the Synapse class constructor
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Union[str, int]]
|
Source code in synapseclient/api/json_schema_services.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
get_invalid_json_schema_validation
async
¶
get_invalid_json_schema_validation(synapse_id: str, *, synapse_client: Optional[Synapse] = None) -> AsyncGenerator[Dict[str, Any], None]
https://rest-docs.synapse.org/rest/POST/entity/id/schema/validation/invalid.html
Get a single page of invalid JSON schema validation results for a container Entity (Project or Folder).
| PARAMETER | DESCRIPTION |
|---|---|
synapse_id
|
Synapse Id
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
Returns: Object matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/schema/ValidationResults.html
Source code in synapseclient/api/json_schema_services.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
get_invalid_json_schema_validation_sync
¶
get_invalid_json_schema_validation_sync(synapse_id: str, *, synapse_client: Optional[Synapse] = None) -> Generator[Dict[str, Any], None, None]
https://rest-docs.synapse.org/rest/POST/entity/id/schema/validation/invalid.html
Get a single page of invalid JSON schema validation results for a container Entity (Project or Folder).
| PARAMETER | DESCRIPTION |
|---|---|
synapse_id
|
Synapse Id
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
Returns: Object matching https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/schema/ValidationResults.html
Source code in synapseclient/api/json_schema_services.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
get_json_schema_derived_keys
async
¶
get_json_schema_derived_keys(synapse_id: str, *, synapse_client: Optional[Synapse] = None) -> List[str]
https://rest-docs.synapse.org/rest/GET/entity/id/derivedKeys.html
Retrieve derived JSON schema keys for a given Synapse entity.
| PARAMETER | DESCRIPTION |
|---|---|
synapse_id
|
The Synapse ID of the entity for which to retrieve derived keys.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
List[str]
|
Source code in synapseclient/api/json_schema_services.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | |
synapseclient.api.table_services
¶
The purpose of this module is to provide any functions that are needed to interact with columns in the Synapse REST API.
Classes¶
ViewEntityType
¶
String enum representing the type of view. This is used to determine the default columns that are added to the table. As defined in the Synapse REST API: https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/table/ViewEntityType.html
Source code in synapseclient/api/table_services.py
17 18 19 20 21 22 23 24 25 26 27 | |
ViewTypeMask
¶
Bit mask representing the types to include in the view. As defined in the Synapse REST API: https://rest-docs.synapse.org/rest/GET/column/tableview/defaults.html
Source code in synapseclient/api/table_services.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
Functions¶
create_table_snapshot
async
¶
create_table_snapshot(table_id: str, comment: Optional[str] = None, label: Optional[str] = None, activity_id: Optional[str] = None, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Union[str, int]]
Creates a table snapshot using the Synapse REST API.
| PARAMETER | DESCRIPTION |
|---|---|
table_id
|
Table ID to create a snapshot for.
TYPE:
|
comment
|
Optional snapshot comment. |
label
|
Optional snapshot label. |
activity_id
|
Optional activity ID or activity instance applied to snapshot version. |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Union[str, int]]
|
A dictionary containing the snapshot response. |
Source code in synapseclient/api/table_services.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
get_columns
async
¶
Get the columns for a Table given the Table's ID.
| PARAMETER | DESCRIPTION |
|---|---|
table_id
|
The ID of the Table to get the columns for.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
Returns: The annotations set in Synapse.
Source code in synapseclient/api/table_services.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
get_column
async
¶
get_column(column_id: str, *, synapse_client: Optional[Synapse] = None) -> Dict[str, Union[str, int]]
Get a single column by ID.
| PARAMETER | DESCRIPTION |
|---|---|
column_id
|
The ID of the column to retrieve.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Union[str, int]]
|
Source code in synapseclient/api/table_services.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
list_columns
async
¶
list_columns(prefix: Optional[str] = None, limit: int = 100, offset: int = 0, *, synapse_client: Optional[Synapse] = None) -> AsyncGenerator[Column, None]
List columns with optional prefix filtering.
| PARAMETER | DESCRIPTION |
|---|---|
prefix
|
Optional prefix to filter columns by name. |
limit
|
Number of columns to retrieve per request to Synapse (pagination parameter). The function will continue retrieving results until all matching columns are returned.
TYPE:
|
offset
|
The index of the first column to return (pagination parameter).
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
Yields: Column instances.
Source code in synapseclient/api/table_services.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
list_columns_sync
¶
list_columns_sync(prefix: Optional[str] = None, limit: int = 100, offset: int = 0, *, synapse_client: Optional[Synapse] = None) -> Generator[Column, None, None]
List columns with optional prefix filtering (synchronous version).
| PARAMETER | DESCRIPTION |
|---|---|
prefix
|
Optional prefix to filter columns by name. |
limit
|
Number of columns to retrieve per request to Synapse (pagination parameter). The function will continue retrieving results until all matching columns are returned.
TYPE:
|
offset
|
The index of the first column to return (pagination parameter).
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
Yields: Column instances.
Source code in synapseclient/api/table_services.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | |
post_columns
async
¶
Creates a batch of synapseclient.models.table.Column's within a single request.
| PARAMETER | DESCRIPTION |
|---|---|
columns
|
The columns to post to Synapse. |
synapse_client
|
If not passed in and caching was not disabled by
|
Source code in synapseclient/api/table_services.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | |
get_default_columns
async
¶
get_default_columns(view_entity_type: Optional[ViewEntityType] = None, view_type_mask: Optional[int] = None, *, synapse_client: Optional[Synapse] = None) -> List[Column]
Get the default columns for a given view type. This will query the following API: https://rest-docs.synapse.org/rest/GET/column/tableview/defaults.html in order to retrieve this information.
If providing a view_type_mask, you can use the ViewTypeMask enum to get the
appropriate value for the entity type you are interested in. ViewTypeMask values are
hexadecimal values, so you can use the | operator to combine them.
Example
To get the default columns for a Dataset, you can use:
import asyncio
from synapseclient.api.table_services import ViewEntityType, ViewTypeMask, get_default_columns
async def main():
view_type_mask = ViewTypeMask.DATASET.value
columns = await get_default_columns(
view_entity_type=ViewEntityType.DATASET,
view_type_mask=view_type_mask,
)
print(columns)
asyncio.run(main())
To get the default columns for a File or a Folder, you can use:
import asyncio
from synapseclient.api.table_services import ViewEntityType, ViewTypeMask, get_default_columns
async def main():
view_type_mask = ViewTypeMask.FILE.value | ViewTypeMask.FOLDER.value
columns = await get_default_columns(
view_entity_type=ViewEntityType.DATASET,
view_type_mask=view_type_mask,
)
print(columns)
asyncio.run(main())
| PARAMETER | DESCRIPTION |
|---|---|
view_type
|
The type of view to get the default columns for.
|
view_type_mask
|
The type of view to get the default columns for. Not required in some cases like a submission view. |
synapse_client
|
If not passed in and caching was not disabled by
|
Returns: The annotations set in Synapse.
Source code in synapseclient/api/table_services.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
synapseclient.api.team_services
¶
This module is responsible for exposing the services defined at: https://rest-docs.synapse.org/rest/#org.sagebionetworks.repo.web.controller.TeamController
Classes¶
Functions¶
post_team_list
async
¶
post_team_list(team_ids: List[int], *, synapse_client: Optional[Synapse] = None) -> Optional[List[Dict[str, Union[str, bool]]]]
Retrieve a list of Teams given their IDs. Invalid IDs in the list are ignored: The results list is simply smaller than the list of IDs passed in.
| PARAMETER | DESCRIPTION |
|---|---|
team_ids
|
List of team IDs to retrieve |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Optional[List[Dict[str, Union[str, bool]]]]
|
List of dictionaries representing https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/Team.html |
Source code in synapseclient/api/team_services.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
create_team
async
¶
create_team(name: str, description: Optional[str] = None, icon: Optional[str] = None, can_public_join: bool = False, can_request_membership: bool = True, *, synapse_client: Optional[Synapse] = None) -> Dict
Creates a new team.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The name of the team to create.
TYPE:
|
description
|
A description of the team. |
icon
|
The FileHandleID of the icon to be used for the team. |
can_public_join
|
Whether the team can be joined by anyone. Defaults to False.
TYPE:
|
can_request_membership
|
Whether the team can request membership. Defaults to True.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict
|
Dictionary representing the created team |
Source code in synapseclient/api/team_services.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
delete_team
async
¶
Deletes a team.
| PARAMETER | DESCRIPTION |
|---|---|
id
|
The ID of the team to delete.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
Source code in synapseclient/api/team_services.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
get_team
async
¶
Finds a team with a given ID or name.
| PARAMETER | DESCRIPTION |
|---|---|
id
|
The ID or name of the team to retrieve. |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict
|
Dictionary representing the team |
Source code in synapseclient/api/team_services.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | |
find_team
async
¶
Retrieve a Teams matching the supplied name fragment
| PARAMETER | DESCRIPTION |
|---|---|
name
|
A team name
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
List[Dict]
|
List of team dictionaries |
Source code in synapseclient/api/team_services.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
get_team_members
async
¶
Lists the members of the given team.
| PARAMETER | DESCRIPTION |
|---|---|
team
|
A team ID or name. |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
List[Dict]
|
List of team member dictionaries |
Source code in synapseclient/api/team_services.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |
send_membership_invitation
async
¶
send_membership_invitation(team_id: int, invitee_id: Optional[str] = None, invitee_email: Optional[str] = None, message: Optional[str] = None, *, synapse_client: Optional[Synapse] = None) -> Dict
Create a membership invitation and send an email notification to the invitee.
| PARAMETER | DESCRIPTION |
|---|---|
team_id
|
Synapse team ID
TYPE:
|
invitee_id
|
Synapse username or profile id of user |
invitee_email
|
Email of user |
message
|
Additional message for the user getting invited to the team. |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict
|
MembershipInvitation dictionary |
Source code in synapseclient/api/team_services.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
get_team_open_invitations
async
¶
get_team_open_invitations(team: Union[int, str], *, synapse_client: Optional[Synapse] = None) -> List[Dict]
Retrieve the open requests submitted to a Team
| PARAMETER | DESCRIPTION |
|---|---|
team
|
A team ID or name. |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
List[Dict]
|
List of MembershipRequest dictionaries |
Source code in synapseclient/api/team_services.py
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
get_membership_status
async
¶
get_membership_status(user_id: str, team: Union[int, str], *, synapse_client: Optional[Synapse] = None) -> Dict
Retrieve a user's Team Membership Status bundle.
| PARAMETER | DESCRIPTION |
|---|---|
user_id
|
Synapse user ID
TYPE:
|
team
|
A team ID or name. |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict
|
Dictionary of TeamMembershipStatus: https://rest-docs.synapse.org/rest/org/sagebionetworks/repo/model/TeamMembershipStatus.html |
Source code in synapseclient/api/team_services.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
delete_membership_invitation
async
¶
delete_membership_invitation(invitation_id: str, *, synapse_client: Optional[Synapse] = None) -> None
Delete an invitation. Note: The client must be an administrator of the Team referenced by the invitation or the invitee to make this request.
| PARAMETER | DESCRIPTION |
|---|---|
invitation_id
|
Open invitation id
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
Source code in synapseclient/api/team_services.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
invite_to_team
async
¶
invite_to_team(team: Union[int, str], user: Optional[str] = None, invitee_email: Optional[str] = None, message: Optional[str] = None, force: bool = False, *, synapse_client: Optional[Synapse] = None) -> Optional[Dict]
Invite user to a Synapse team via Synapse username or email (choose one or the other)
| PARAMETER | DESCRIPTION |
|---|---|
team
|
A team ID or name. |
user
|
Synapse username or profile id of user |
invitee_email
|
Email of user |
message
|
Additional message for the user getting invited to the team. |
force
|
If an open invitation exists for the invitee, the old invite will be cancelled.
TYPE:
|
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Optional[Dict]
|
MembershipInvitation or None if user is already a member |
Source code in synapseclient/api/team_services.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 | |
synapseclient.api.user_services
¶
This module is responsible for exposing the services defined at: https://rest-docs.synapse.org/rest/#org.sagebionetworks.repo.web.controller.UserGroupController
Classes¶
Functions¶
get_user_group_headers_batch
async
¶
get_user_group_headers_batch(ids: List[str], *, synapse_client: Optional[Synapse] = None) -> List[Dict[str, Union[str, bool]]]
Batch get UserGroupHeaders. This fetches information about a collection of users or groups, specified by Synapse IDs.
| PARAMETER | DESCRIPTION |
|---|---|
ids
|
List of user/group IDs to retrieve |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
List[Dict[str, Union[str, bool]]]
|
List representing "children" in |
List[Dict[str, Union[str, bool]]]
|
Source code in synapseclient/api/user_services.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | |
get_user_profile_by_id
async
¶
get_user_profile_by_id(id: Optional[int] = None, *, synapse_client: Optional[Synapse] = None) -> Dict
Get the details about a Synapse user by ID. Retrieves information on the current user if 'id' is omitted.
| PARAMETER | DESCRIPTION |
|---|---|
id
|
The ownerId of a user |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict
|
The user profile for the user of interest. |
Source code in synapseclient/api/user_services.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
get_user_profile_by_username
async
¶
get_user_profile_by_username(username: Optional[str] = None, *, synapse_client: Optional[Synapse] = None) -> Dict
Get the details about a Synapse user by username. Retrieves information on the current user if 'username' is omitted or empty string.
| PARAMETER | DESCRIPTION |
|---|---|
username
|
The userName of a user |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
Dict
|
The user profile for the user of interest. |
Source code in synapseclient/api/user_services.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
is_user_certified
async
¶
Determines whether a Synapse user is a certified user.
| PARAMETER | DESCRIPTION |
|---|---|
user
|
Synapse username or Id |
synapse_client
|
If not passed in and caching was not disabled by
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the Synapse user is certified |
Source code in synapseclient/api/user_services.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |