Async Object-Orientated Models
Contained within this file are experimental interfaces for working with the Synapse Python Client. Unless otherwise noted these interfaces are subject to change at any time. Use at your own risk.
These APIs also introduce AsyncIO to the client.
Sample Scripts:¶
See this page for sample scripts. The sample scripts are from a synchronous context, replace any of the method calls with the async counter-party and they will be functionally equivalent.
API reference¶
synapseclient.models.Project
dataclass
¶
Bases: ProjectSynchronousProtocol, AccessControllable, StorableContainer
A Project is a top-level container for organizing data in Synapse.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
The unique immutable ID for this project. A new ID will be generated for new Projects. Once issued, this ID is guaranteed to never change or be re-issued
TYPE:
|
name |
The name of this project. Must be 256 characters or less. Names may only contain: letters, numbers, spaces, underscores, hyphens, periods, plus signs, apostrophes, and parentheses
TYPE:
|
description |
The description of this entity. Must be 1000 characters or less.
TYPE:
|
etag |
Synapse employs an Optimistic Concurrency Control (OCC) scheme to handle concurrent updates. Since the E-Tag changes every time an entity is updated it is used to detect when a client's current representation of an entity is out-of-date.
TYPE:
|
created_on |
The date this entity was created.
TYPE:
|
modified_on |
The date this entity was last modified.
TYPE:
|
created_by |
The ID of the user that created this entity.
TYPE:
|
modified_by |
The ID of the user that last modified this entity.
TYPE:
|
alias |
The project alias for use in friendly project urls.
TYPE:
|
files |
Any files that are at the root directory of the project.
TYPE:
|
folders |
Any folders that are at the root directory of the project.
TYPE:
|
annotations |
Additional metadata associated with the folder. The key is the name
of your desired annotations. The value is an object containing a list of
values (use empty list to represent no values for key) and the value type
associated with all values in the list. To remove all annotations set this
to an empty dict
TYPE:
|
Creating a project
This example shows how to create a project
from synapseclient.models import Project, File
import synapseclient
synapseclient.login()
my_annotations = {
"my_single_key_string": "a",
"my_key_string": ["b", "a", "c"],
}
project = Project(
name="My unique project name",
annotations=my_annotations,
description="This is a project with random data.",
)
project = project.store()
print(project)
Storing several files to a project
This example shows how to store several files to a project
file_1 = File(
path=path_to_file_1,
name=name_of_file_1,
)
file_2 = File(
path=path_to_file_2,
name=name_of_file_2,
)
project.files = [file_1, file_2]
project = project.store()
Source code in synapseclient/models/project.py
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 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 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 232 233 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 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 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 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 432 433 434 435 436 437 438 439 440 441 442 443 444 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 492 493 494 495 496 497 498 | |
Functions¶
get_async(synapse_client=None)
async
¶
Get the project metadata from Synapse.
| PARAMETER | DESCRIPTION |
|---|---|
synapse_client
|
If not passed in or None this will use the last client from
the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Project
|
The project object. |
Using this method
Retrieve the project from Synapse using ID
project = await Project(id="syn123").get_async()
Retrieve the project from Synapse using Name
project = await Project(name="my_project").get_async()
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the project ID or Name is not set. |
SynapseNotFoundError
|
If the project is not found in Synapse. |
Source code in synapseclient/models/project.py
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 363 364 365 366 367 | |
store_async(failure_strategy=FailureStrategy.LOG_EXCEPTION, synapse_client=None)
async
¶
Store project, files, and folders to synapse. If you have any files or folders
attached to this project they will be stored as well. You may attach files
and folders to this project by setting the files and folders attributes.
By default the store operation will non-destructively update the project if
you have not already retrieved the project from Synapse. If you have already
retrieved the project from Synapse then the store operation will be destructive
and will overwrite the project with the current state of this object. See the
create_or_update attribute for more information.
| PARAMETER | DESCRIPTION |
|---|---|
failure_strategy
|
Determines how to handle failures when storing attached Files and Folders under this Project and an exception occurs.
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client from
the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Project
|
The project object. |
Using this method to update the description
Store the project to Synapse using ID
project = await Project(id="syn123", description="new").store_async()
Store the project to Synapse using Name
project = await Project(name="my_project", description="new").store_async()
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the project name is not set. |
Source code in synapseclient/models/project.py
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 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 | |
delete_async(synapse_client=None)
async
¶
Delete the project from Synapse.
| PARAMETER | DESCRIPTION |
|---|---|
synapse_client
|
If not passed in or None this will use the last client from
the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
None
|
None |
Using this method
Delete the project from Synapse using ID
await Project(id="syn123").delete_async()
Delete the project from Synapse using Name
await Project(name="my_project").delete_async()
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the project ID or Name is not set. |
SynapseNotFoundError
|
If the project is not found in Synapse. |
Source code in synapseclient/models/project.py
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 | |
sync_from_synapse_async(path=None, recursive=True, download_file=True, if_collision=COLLISION_OVERWRITE_LOCAL, failure_strategy=FailureStrategy.LOG_EXCEPTION, synapse_client=None)
async
¶
Sync this container and all possible sub-folders from Synapse. By default this
will download the files that are found and it will populate the
files and folders attributes with the found files and folders. If you only
want to retrieve the full tree of metadata about your container specify
download_file as False.
This works similar to synapseutils.syncFromSynapse, however, this does not currently support the writing of data to a manifest TSV file. This will be a future enhancement.
Only Files and Folders are supported at this time to be synced from synapse.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
An optional path where the file hierarchy will be reproduced. If not specified the files will by default be placed in the synapseCache.
TYPE:
|
recursive
|
Whether or not to recursively get the entire hierarchy of the folder and sub-folders.
TYPE:
|
download_file
|
Whether to download the files found or not.
TYPE:
|
if_collision
|
Determines how to handle file collisions. May be
TYPE:
|
failure_strategy
|
Determines how to handle failures when retrieving children under this Folder and an exception occurs.
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client from
the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Self
|
The object that was called on. This will be the same object that was called on to start the sync. |
Using this function
Suppose I want to walk the immediate children of a folder without downloading the files:
from synapseclient import Synapse
from synapseclient.models import Folder
syn = Synapse()
syn.login()
my_folder = Folder(id="syn12345")
await my_folder.sync_from_synapse_async(download_file=False, recursive=False)
for folder in my_folder.folders:
print(folder.name)
for file in my_folder.files:
print(file.name)
Suppose I want to download the immediate children of a folder:
from synapseclient import Synapse
from synapseclient.models import Folder
syn = Synapse()
syn.login()
my_folder = Folder(id="syn12345")
await my_folder.sync_from_synapse_async(path="/path/to/folder", recursive=False)
for folder in my_folder.folders:
print(folder.name)
for file in my_folder.files:
print(file.name)
Suppose I want to download the immediate all children of a Project and all sub-folders and files:
from synapseclient import Synapse
from synapseclient.models import Project
syn = Synapse()
syn.login()
my_project = Project(id="syn12345")
await my_project.sync_from_synapse_async(path="/path/to/folder")
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the folder does not have an id set. |
A sequence diagram for this method is as follows:
sequenceDiagram
autonumber
participant project_or_folder
activate project_or_folder
project_or_folder->>sync_from_synapse: Recursive search and download files
activate sync_from_synapse
opt Current instance not retrieved from Synapse
sync_from_synapse->>project_or_folder: Call `.get()` method
project_or_folder-->>sync_from_synapse: .
end
loop For each return of the generator
sync_from_synapse->>client: call `.getChildren()` method
client-->>sync_from_synapse: .
note over sync_from_synapse: Append to a running list
end
loop For each child
note over sync_from_synapse: Create all `pending_tasks` at current depth
alt Child is File
note over sync_from_synapse: Append `file.get()` method
else Child is Folder
note over sync_from_synapse: Append `folder.get()` method
alt Recursive is True
note over sync_from_synapse: Append `folder.sync_from_synapse()` method
end
end
end
loop For each task in pending_tasks
par `file.get()`
sync_from_synapse->>File: Retrieve File metadata and Optionally download
File->>client: `.get()`
client-->>File: .
File-->>sync_from_synapse: .
and `folder.get()`
sync_from_synapse->>Folder: Retrieve Folder metadataa
Folder->>client: `.get()`
client-->>Folder: .
Folder-->>sync_from_synapse: .
and `folder.sync_from_synapse_async()`
note over sync_from_synapse: This is a recursive call to `sync_from_synapse`
sync_from_synapse->>sync_from_synapse: Recursive call to `.sync_from_synapse_async()`
end
end
deactivate sync_from_synapse
deactivate project_or_folder
Source code in synapseclient/models/mixins/storable_container.py
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 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 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 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
get_permissions_async(synapse_client=None)
async
¶
Get the permissions that the caller has on an Entity.
| PARAMETER | DESCRIPTION |
|---|---|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Permissions
|
A Permissions object |
Using this function:
Getting permissions for a Synapse Entity
permissions = await File(id="syn123").get_permissions_async()
Getting access types list from the Permissions object
permissions.access_types
Source code in synapseclient/models/mixins/access_control.py
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 | |
get_acl_async(principal_id=None, synapse_client=None)
async
¶
Get the ACL that a user or group has on an Entity.
| PARAMETER | DESCRIPTION |
|---|---|
principal_id
|
Identifier of a user or group (defaults to PUBLIC users)
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
List[str]
|
An array containing some combination of ['READ', 'UPDATE', 'CREATE', 'DELETE', 'DOWNLOAD', 'MODERATE', 'CHANGE_PERMISSIONS', 'CHANGE_SETTINGS'] or an empty array |
Source code in synapseclient/models/mixins/access_control.py
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 | |
set_permissions_async(principal_id=None, access_type=None, modify_benefactor=False, warn_if_inherits=True, overwrite=True, synapse_client=None)
async
¶
Sets permission that a user or group has on an Entity. An Entity may have its own ACL or inherit its ACL from a benefactor.
| PARAMETER | DESCRIPTION |
|---|---|
principal_id
|
Identifier of a user or group.
TYPE:
|
access_type
|
Type of permission to be granted. One or more of CREATE, READ, DOWNLOAD, UPDATE, DELETE, CHANGE_PERMISSIONS. Defaults to ['READ', 'DOWNLOAD']
TYPE:
|
modify_benefactor
|
Set as True when modifying a benefactor's ACL
TYPE:
|
warn_if_inherits
|
Set as False, when creating a new ACL. Trying to modify the ACL of an Entity that inherits its ACL will result in a warning
TYPE:
|
overwrite
|
By default this function overwrites existing permissions for the specified user. Set this flag to False to add new permissions non-destructively.
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Union[str, list]]
|
An Access Control List object |
Setting permissions
Grant all registered users download access
await File(id="syn123").set_permissions_async(principal_id=273948, access_type=['READ','DOWNLOAD'])
Grant the public view access
await File(id="syn123").set_permissions_async(principal_id=273949, access_type=['READ'])
Source code in synapseclient/models/mixins/access_control.py
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 157 158 159 160 161 162 | |
synapseclient.models.Folder
dataclass
¶
Bases: FolderSynchronousProtocol, AccessControllable, StorableContainer
Folder is a hierarchical container for organizing data in Synapse.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
The unique immutable ID for this folder. A new ID will be generated for new Folders. Once issued, this ID is guaranteed to never change or be re-issued.
TYPE:
|
name |
The name of this folder. Must be 256 characters or less. Names may only contain: letters, numbers, spaces, underscores, hyphens, periods, plus signs, apostrophes, and parentheses.
TYPE:
|
parent_id |
The ID of the Project or Folder that is the parent of this Folder.
TYPE:
|
description |
The description of this entity. Must be 1000 characters or less.
TYPE:
|
etag |
(Read Only) Synapse employs an Optimistic Concurrency Control (OCC) scheme to handle concurrent updates. Since the E-Tag changes every time an entity is updated it is used to detect when a client's current representation of an entity is out-of-date.
TYPE:
|
created_on |
(Read Only) The date this entity was created.
TYPE:
|
modified_on |
(Read Only) The date this entity was last modified.
TYPE:
|
created_by |
(Read Only) The ID of the user that created this entity.
TYPE:
|
modified_by |
(Read Only) The ID of the user that last modified this entity.
TYPE:
|
files |
Files that exist within this folder.
TYPE:
|
folders |
Folders that exist within this folder.
TYPE:
|
annotations |
Additional metadata associated with the folder. The key is the name
of your desired annotations. The value is an object containing a list of
values (use empty list to represent no values for key) and the value type
associated with all values in the list. To remove all annotations set this
to an empty dict
TYPE:
|
Source code in synapseclient/models/folder.py
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 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 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 232 233 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 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 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 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 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | |
Functions¶
get_async(parent=None, synapse_client=None)
async
¶
Get the folder metadata from Synapse. You are able to find a folder by either the id or the name and parent_id.
| PARAMETER | DESCRIPTION |
|---|---|
parent
|
The parent folder or project this folder exists under. |
synapse_client
|
If not passed in or None this will use the last client from
the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Folder
|
The folder object. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the folder does not have an id or a
(name and ( |
Source code in synapseclient/models/folder.py
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 | |
store_async(parent=None, failure_strategy=FailureStrategy.LOG_EXCEPTION, synapse_client=None)
async
¶
Store folders and files to synapse. If you have any files or folders attached
to this folder they will be stored as well. You may attach files and folders
to this folder by setting the files and folders attributes.
By default the store operation will non-destructively update the folder if
you have not already retrieved the folder from Synapse. If you have already
retrieved the folder from Synapse then the store operation will be destructive
and will overwrite the folder with the current state of this object. See the
create_or_update attribute for more information.
| PARAMETER | DESCRIPTION |
|---|---|
parent
|
The parent folder or project to store the folder in. |
failure_strategy
|
Determines how to handle failures when storing attached Files and Folders under this Folder and an exception occurs.
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client from
the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Folder
|
The folder object. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the folder does not have an id or a
(name and ( |
Source code in synapseclient/models/folder.py
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 232 233 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 278 279 280 281 282 283 284 285 286 | |
delete_async(synapse_client=None)
async
¶
Delete the folder from Synapse by its id.
| PARAMETER | DESCRIPTION |
|---|---|
synapse_client
|
If not passed in or None this will use the last client from
the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
None
|
None |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the folder does not have an id set. |
Source code in synapseclient/models/folder.py
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 | |
copy_async(parent_id, copy_annotations=True, exclude_types=None, file_update_existing=False, file_copy_activity='traceback', synapse_client=None)
async
¶
Copy the folder to another Synapse location. This will recursively copy all Tables, Links, Files, and Folders within the folder.
| PARAMETER | DESCRIPTION |
|---|---|
parent_id
|
Synapse ID of a folder/project that the copied entity is being copied to
TYPE:
|
copy_annotations
|
True to copy the annotations.
TYPE:
|
exclude_types
|
A list of entity types ['file', 'table', 'link'] which determines which entity types to not copy. Defaults to an empty list.
TYPE:
|
file_update_existing
|
When the destination has a file that has the same name, users can choose to update that file.
TYPE:
|
file_copy_activity
|
Has three options to set the activity of the copied file:
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client from
the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Folder
|
The copied folder object. |
Using this function
Assuming you have a folder with the ID "syn123" and you want to copy it to a project with the ID "syn456":
new_folder_instance = await Folder(id="syn123").copy_async(parent_id="syn456")
Copy the folder but do not persist annotations:
new_folder_instance = await Folder(id="syn123").copy_async(parent_id="syn456", copy_annotations=False)
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the folder does not have an ID and parent_id to copy. |
Source code in synapseclient/models/folder.py
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 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 | |
sync_from_synapse_async(path=None, recursive=True, download_file=True, if_collision=COLLISION_OVERWRITE_LOCAL, failure_strategy=FailureStrategy.LOG_EXCEPTION, synapse_client=None)
async
¶
Sync this container and all possible sub-folders from Synapse. By default this
will download the files that are found and it will populate the
files and folders attributes with the found files and folders. If you only
want to retrieve the full tree of metadata about your container specify
download_file as False.
This works similar to synapseutils.syncFromSynapse, however, this does not currently support the writing of data to a manifest TSV file. This will be a future enhancement.
Only Files and Folders are supported at this time to be synced from synapse.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
An optional path where the file hierarchy will be reproduced. If not specified the files will by default be placed in the synapseCache.
TYPE:
|
recursive
|
Whether or not to recursively get the entire hierarchy of the folder and sub-folders.
TYPE:
|
download_file
|
Whether to download the files found or not.
TYPE:
|
if_collision
|
Determines how to handle file collisions. May be
TYPE:
|
failure_strategy
|
Determines how to handle failures when retrieving children under this Folder and an exception occurs.
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client from
the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Self
|
The object that was called on. This will be the same object that was called on to start the sync. |
Using this function
Suppose I want to walk the immediate children of a folder without downloading the files:
from synapseclient import Synapse
from synapseclient.models import Folder
syn = Synapse()
syn.login()
my_folder = Folder(id="syn12345")
await my_folder.sync_from_synapse_async(download_file=False, recursive=False)
for folder in my_folder.folders:
print(folder.name)
for file in my_folder.files:
print(file.name)
Suppose I want to download the immediate children of a folder:
from synapseclient import Synapse
from synapseclient.models import Folder
syn = Synapse()
syn.login()
my_folder = Folder(id="syn12345")
await my_folder.sync_from_synapse_async(path="/path/to/folder", recursive=False)
for folder in my_folder.folders:
print(folder.name)
for file in my_folder.files:
print(file.name)
Suppose I want to download the immediate all children of a Project and all sub-folders and files:
from synapseclient import Synapse
from synapseclient.models import Project
syn = Synapse()
syn.login()
my_project = Project(id="syn12345")
await my_project.sync_from_synapse_async(path="/path/to/folder")
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the folder does not have an id set. |
A sequence diagram for this method is as follows:
sequenceDiagram
autonumber
participant project_or_folder
activate project_or_folder
project_or_folder->>sync_from_synapse: Recursive search and download files
activate sync_from_synapse
opt Current instance not retrieved from Synapse
sync_from_synapse->>project_or_folder: Call `.get()` method
project_or_folder-->>sync_from_synapse: .
end
loop For each return of the generator
sync_from_synapse->>client: call `.getChildren()` method
client-->>sync_from_synapse: .
note over sync_from_synapse: Append to a running list
end
loop For each child
note over sync_from_synapse: Create all `pending_tasks` at current depth
alt Child is File
note over sync_from_synapse: Append `file.get()` method
else Child is Folder
note over sync_from_synapse: Append `folder.get()` method
alt Recursive is True
note over sync_from_synapse: Append `folder.sync_from_synapse()` method
end
end
end
loop For each task in pending_tasks
par `file.get()`
sync_from_synapse->>File: Retrieve File metadata and Optionally download
File->>client: `.get()`
client-->>File: .
File-->>sync_from_synapse: .
and `folder.get()`
sync_from_synapse->>Folder: Retrieve Folder metadataa
Folder->>client: `.get()`
client-->>Folder: .
Folder-->>sync_from_synapse: .
and `folder.sync_from_synapse_async()`
note over sync_from_synapse: This is a recursive call to `sync_from_synapse`
sync_from_synapse->>sync_from_synapse: Recursive call to `.sync_from_synapse_async()`
end
end
deactivate sync_from_synapse
deactivate project_or_folder
Source code in synapseclient/models/mixins/storable_container.py
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 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 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 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
get_permissions_async(synapse_client=None)
async
¶
Get the permissions that the caller has on an Entity.
| PARAMETER | DESCRIPTION |
|---|---|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Permissions
|
A Permissions object |
Using this function:
Getting permissions for a Synapse Entity
permissions = await File(id="syn123").get_permissions_async()
Getting access types list from the Permissions object
permissions.access_types
Source code in synapseclient/models/mixins/access_control.py
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 | |
get_acl_async(principal_id=None, synapse_client=None)
async
¶
Get the ACL that a user or group has on an Entity.
| PARAMETER | DESCRIPTION |
|---|---|
principal_id
|
Identifier of a user or group (defaults to PUBLIC users)
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
List[str]
|
An array containing some combination of ['READ', 'UPDATE', 'CREATE', 'DELETE', 'DOWNLOAD', 'MODERATE', 'CHANGE_PERMISSIONS', 'CHANGE_SETTINGS'] or an empty array |
Source code in synapseclient/models/mixins/access_control.py
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 | |
set_permissions_async(principal_id=None, access_type=None, modify_benefactor=False, warn_if_inherits=True, overwrite=True, synapse_client=None)
async
¶
Sets permission that a user or group has on an Entity. An Entity may have its own ACL or inherit its ACL from a benefactor.
| PARAMETER | DESCRIPTION |
|---|---|
principal_id
|
Identifier of a user or group.
TYPE:
|
access_type
|
Type of permission to be granted. One or more of CREATE, READ, DOWNLOAD, UPDATE, DELETE, CHANGE_PERMISSIONS. Defaults to ['READ', 'DOWNLOAD']
TYPE:
|
modify_benefactor
|
Set as True when modifying a benefactor's ACL
TYPE:
|
warn_if_inherits
|
Set as False, when creating a new ACL. Trying to modify the ACL of an Entity that inherits its ACL will result in a warning
TYPE:
|
overwrite
|
By default this function overwrites existing permissions for the specified user. Set this flag to False to add new permissions non-destructively.
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Union[str, list]]
|
An Access Control List object |
Setting permissions
Grant all registered users download access
await File(id="syn123").set_permissions_async(principal_id=273948, access_type=['READ','DOWNLOAD'])
Grant the public view access
await File(id="syn123").set_permissions_async(principal_id=273949, access_type=['READ'])
Source code in synapseclient/models/mixins/access_control.py
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 157 158 159 160 161 162 | |
synapseclient.models.File
dataclass
¶
Bases: FileSynchronousProtocol, AccessControllable
A file within Synapse.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
The unique immutable ID for this file. A new ID will be generated for new Files. Once issued, this ID is guaranteed to never change or be re-issued.
TYPE:
|
name |
The name of this entity. Must be 256 characters or less. Names may only contain: letters, numbers, spaces, underscores, hyphens, periods, plus signs, apostrophes, and parentheses. If not specified, the name will be derived from the file name.
TYPE:
|
path |
The path to the file on disk.
TYPE:
|
content_type |
Used to manually specify Content-type header, for example 'application/png' or 'application/json; charset=UTF-8'. If not specified, the content type will be derived from the file extension. (Create Only) This can be specified only during the initial store of this file. In order to change this after the File has been created use synapseclient.models.File.change_metadata.
TYPE:
|
description |
The description of this file. Must be 1000 characters or less.
TYPE:
|
etag |
(Read Only) Synapse employs an Optimistic Concurrency Control (OCC) scheme to handle concurrent updates. Since the E-Tag changes every time an entity is updated it is used to detect when a client's current representation of an entity is out-of-date.
TYPE:
|
created_on |
(Read Only) The date this entity was created.
TYPE:
|
modified_on |
(Read Only) The date this entity was last modified.
TYPE:
|
created_by |
(Read Only) The ID of the user that created this entity.
TYPE:
|
modified_by |
(Read Only) The ID of the user that last modified this entity.
TYPE:
|
parent_id |
The ID of the Entity that is the parent of this Entity. Setting this to a new value and storing it will move this File under the new parent.
TYPE:
|
version_number |
(Read Only) The version number issued to this version on the object.
TYPE:
|
version_label |
The version label for this entity
TYPE:
|
version_comment |
The version comment for this entity
TYPE:
|
is_latest_version |
(Read Only) If this is the latest version of the object.
TYPE:
|
data_file_handle_id |
ID of the file associated with this entity. You may define an existing data_file_handle_id to use the existing data_file_handle_id. The creator of the file must also be the owner of the data_file_handle_id to have permission to store the file.
TYPE:
|
file_handle |
(Read Only) The file handle associated with this entity.
TYPE:
|
activity |
The Activity model represents the main record of Provenance in Synapse. It is analygous to the Activity defined in the W3C Specification on Provenance.
TYPE:
|
annotations |
Additional metadata associated with the folder. The key is the name
of your desired annotations. The value is an object containing a list of
values (use empty list to represent no values for key) and the value type
associated with all values in the list. To remove all annotations set this
to an empty dict
TYPE:
|
create_or_update |
(Store only) Indicates whether the method should automatically perform an update if the 'obj' conflicts with an existing Synapse object.
TYPE:
|
force_version |
(Store only) Indicates whether the method should increment the version of the object even if nothing has changed. An update to the MD5 of the file will force a version update regardless of this flag.
TYPE:
|
is_restricted |
(Store only) If set to true, an email will be sent to the Synapse access control team to start the process of adding terms-of-use or review board approval for this entity. You will be contacted with regards to the specific data being restricted and the requirements of access.
TYPE:
|
synapse_store |
(Store only) Whether the File should be uploaded or if false: only the path should be stored when synapseclient.models.File.store is called.
TYPE:
|
download_file |
(Get only) If True the file will be downloaded.
TYPE:
|
download_location |
(Get only) The location to download the file to.
TYPE:
|
if_collision |
(Get only) Determines how to handle file collisions. Defaults to "keep.both". May be:
TYPE:
|
synapse_container_limit |
(Get only) A Synanpse ID used to limit the search in Synapse if file is specified as a local file. That is, if the file is stored in multiple locations in Synapse only the ones in the specified folder/project will be returned.
TYPE:
|
Source code in synapseclient/models/file.py
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 171 172 173 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 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 232 233 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 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 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 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 432 433 434 435 436 437 438 439 440 441 442 443 444 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 492 493 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 519 520 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 547 548 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 620 621 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 680 681 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 733 734 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 777 778 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 830 831 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 871 872 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 | |
Functions¶
get_async(include_activity=False, synapse_client=None)
async
¶
Get the file from Synapse. You may retrieve a File entity by either:
- id
- path
If you specify both, the id will take precedence.
If you specify the path and the file is stored in multiple locations in
Synapse only the first one found will be returned. The other matching files
will be printed to the console.
You may also specify a version_number to get a specific version of the file.
| PARAMETER | DESCRIPTION |
|---|---|
include_activity
|
If True the activity will be included in the file if it exists.
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client from
the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
File
|
The file object. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the file does not have an ID or path to get. |
Using this function
Assuming you have a file with the ID "syn123":
file_instance = await File(id="syn123").get_async()
Assuming you have a file at the path "path/to/file.txt":
file_instance = await File(path="path/to/file.txt").get_async()
Source code in synapseclient/models/file.py
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 680 681 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 | |
store_async(parent=None, synapse_client=None)
async
¶
Store the file in Synapse. With this method you may:
- Upload a file into Synapse
- Update the metadata of a file in Synapse
- Store a File object in Synapse without updating a file by setting
synapse_storeto False. - Change the name of a file in Synapse by setting the
nameattribute of the File object. Also see the synapseclient.models.File.change_metadata method for changing the name of the downloaded file. - Moving a file to a new parent by setting the
parent_idattribute of the File object.
| PARAMETER | DESCRIPTION |
|---|---|
parent
|
The parent folder or project to store the file in. May also be
specified in the File object. If both are provided the parent passed
into |
synapse_client
|
If not passed in or None this will use the last client from
the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
File
|
The file object. |
Using this function
File with the ID syn123 at path path/to/file.txt:
file_instance = await File(id="syn123", path="path/to/file.txt").store_async()
File at the path path/to/file.txt and a parent folder with the ID syn456:
file_instance = await File(path="path/to/file.txt", parent_id="syn456").store_async()
File at the path path/to/file.txt and a parent folder with the ID syn456:
file_instance = await File(path="path/to/file.txt").store_async(parent=Folder(id="syn456"))
Rename a file (Does not update the file on disk or the name of the downloaded file):
file_instance = await File(id="syn123", download_file=False).get_async()
print(file_instance.name) ## prints, e.g., "my_file.txt"
await file_instance.change_metadata_async(name="my_new_name_file.txt")
Rename a file, and the name of the file as downloaded (Does not update the file on disk):
file_instance = await File(id="syn123", download_file=False).get_async()
print(file_instance.name) ## prints, e.g., "my_file.txt"
await file_instance.change_metadata_async(name="my_new_name_file.txt", download_as="my_new_name_file.txt")
Source code in synapseclient/models/file.py
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 508 509 510 511 512 513 514 515 516 517 518 519 520 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 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 | |
copy_async(parent_id, update_existing=False, copy_annotations=True, copy_activity='traceback', synapse_client=None)
async
¶
Copy the file to another Synapse location. Defaults to the latest version of the file, or the version_number specified in the instance.
| PARAMETER | DESCRIPTION |
|---|---|
parent_id
|
Synapse ID of a folder/project that the copied entity is being copied to
TYPE:
|
update_existing
|
When the destination has a file that has the same name, users can choose to update that file.
TYPE:
|
copy_annotations
|
True to copy the annotations.
TYPE:
|
copy_activity
|
Has three options to set the activity of the copied file:
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client from
the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
File
|
The copied file object. |
Using this function
Assuming you have a file with the ID "syn123" and you want to copy it to a folder with the ID "syn456":
new_file_instance = await File(id="syn123").copy_async(parent_id="syn456")
Copy the file but do not persist annotations or activity:
new_file_instance = await File(id="syn123").copy_async(parent_id="syn456", copy_annotations=False, copy_activity=None)
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the file does not have an ID and parent_id to copy. |
Source code in synapseclient/models/file.py
825 826 827 828 829 830 831 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 871 872 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 | |
delete_async(version_only=False, synapse_client=None)
async
¶
Delete the file from Synapse using the ID of the file.
| PARAMETER | DESCRIPTION |
|---|---|
version_only
|
If True only the version specified in the
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client from
the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
None
|
None |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the file does not have an ID to delete. |
ValueError
|
If the file does not have a version number to delete a version,
and |
Using this function
Assuming you have a file with the ID "syn123":
await File(id="syn123").delete_async()
Source code in synapseclient/models/file.py
773 774 775 776 777 778 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 | |
from_id_async(synapse_id, synapse_client=None)
async
classmethod
¶
Wrapper for synapseclient.models.File.get.
| PARAMETER | DESCRIPTION |
|---|---|
synapse_id
|
The ID of the file in Synapse.
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
File
|
The file object. |
Using this function
Assuming you have a file with the ID "syn123":
file_instance = await File.from_id_async(synapse_id="syn123")
Source code in synapseclient/models/file.py
718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 | |
from_path_async(path, synapse_client=None)
async
classmethod
¶
Get the file from Synapse. If the path of the file matches multiple files within Synapse the first one found will be returned. The other matching files will be printed to the console.
Wrapper for synapseclient.models.File.get.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
The path to the file on disk.
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
File
|
The file object. |
Using this function
Assuming you have a file at the path "path/to/file.txt":
file_instance = await File.from_path_async(path="path/to/file.txt")
Source code in synapseclient/models/file.py
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 | |
change_metadata_async(name=None, download_as=None, content_type=None, synapse_client=None)
async
¶
Change File Entity metadata for properties that are immutable after creation through the store method.
| PARAMETER | DESCRIPTION |
|---|---|
name
|
Specify to change the filename of a file as seen on Synapse.
TYPE:
|
download_as
|
Specify filename to change the filename of a filehandle.
TYPE:
|
content_type
|
Specify content type to change the content type of a filehandle.
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client from
the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
File
|
The file object. |
Using this function
Can be used to change the filename, the filename when the file is downloaded, or the file content-type without downloading:
file_entity = await File(id="syn123", download_file=False).get_async()
print(os.path.basename(file_entity.path)) ## prints, e.g., "my_file.txt"
file_entity = await file_entity.change_metadata_async(name="my_new_name_file.txt", download_as="my_new_downloadAs_name_file.txt", content_type="text/plain")
print(os.path.basename(file_entity.path)) ## prints, "my_new_downloadAs_name_file.txt"
print(file_entity.name) ## prints, "my_new_name_file.txt"
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the file does not have an ID to change metadata. |
Source code in synapseclient/models/file.py
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 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 | |
get_permissions_async(synapse_client=None)
async
¶
Get the permissions that the caller has on an Entity.
| PARAMETER | DESCRIPTION |
|---|---|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Permissions
|
A Permissions object |
Using this function:
Getting permissions for a Synapse Entity
permissions = await File(id="syn123").get_permissions_async()
Getting access types list from the Permissions object
permissions.access_types
Source code in synapseclient/models/mixins/access_control.py
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 | |
get_acl_async(principal_id=None, synapse_client=None)
async
¶
Get the ACL that a user or group has on an Entity.
| PARAMETER | DESCRIPTION |
|---|---|
principal_id
|
Identifier of a user or group (defaults to PUBLIC users)
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
List[str]
|
An array containing some combination of ['READ', 'UPDATE', 'CREATE', 'DELETE', 'DOWNLOAD', 'MODERATE', 'CHANGE_PERMISSIONS', 'CHANGE_SETTINGS'] or an empty array |
Source code in synapseclient/models/mixins/access_control.py
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 | |
set_permissions_async(principal_id=None, access_type=None, modify_benefactor=False, warn_if_inherits=True, overwrite=True, synapse_client=None)
async
¶
Sets permission that a user or group has on an Entity. An Entity may have its own ACL or inherit its ACL from a benefactor.
| PARAMETER | DESCRIPTION |
|---|---|
principal_id
|
Identifier of a user or group.
TYPE:
|
access_type
|
Type of permission to be granted. One or more of CREATE, READ, DOWNLOAD, UPDATE, DELETE, CHANGE_PERMISSIONS. Defaults to ['READ', 'DOWNLOAD']
TYPE:
|
modify_benefactor
|
Set as True when modifying a benefactor's ACL
TYPE:
|
warn_if_inherits
|
Set as False, when creating a new ACL. Trying to modify the ACL of an Entity that inherits its ACL will result in a warning
TYPE:
|
overwrite
|
By default this function overwrites existing permissions for the specified user. Set this flag to False to add new permissions non-destructively.
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Union[str, list]]
|
An Access Control List object |
Setting permissions
Grant all registered users download access
await File(id="syn123").set_permissions_async(principal_id=273948, access_type=['READ','DOWNLOAD'])
Grant the public view access
await File(id="syn123").set_permissions_async(principal_id=273949, access_type=['READ'])
Source code in synapseclient/models/mixins/access_control.py
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 157 158 159 160 161 162 | |
synapseclient.models.Table
dataclass
¶
Bases: TableSynchronousProtocol, AccessControllable
A Table represents the metadata of a table.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
The unique immutable ID for this table. A new ID will be generated for new Tables. Once issued, this ID is guaranteed to never change or be re-issued
TYPE:
|
name |
The name of this table. Must be 256 characters or less. Names may only contain: letters, numbers, spaces, underscores, hyphens, periods, plus signs, apostrophes, and parentheses
TYPE:
|
parent_id |
The ID of the Entity that is the parent of this table.
TYPE:
|
columns |
The columns of this table.
TYPE:
|
description |
The description of this entity. Must be 1000 characters or less.
TYPE:
|
etag |
Synapse employs an Optimistic Concurrency Control (OCC) scheme to handle concurrent updates. Since the E-Tag changes every time an entity is updated it is used to detect when a client's current representation of an entity is out-of-date.
TYPE:
|
created_on |
The date this table was created.
TYPE:
|
created_by |
The ID of the user that created this table.
TYPE:
|
modified_on |
The date this table was last modified. In YYYY-MM-DD-Thh:mm:ss.sssZ format
TYPE:
|
modified_by |
The ID of the user that last modified this table.
TYPE:
|
version_number |
The version number issued to this version on the object.
TYPE:
|
version_label |
The version label for this table
TYPE:
|
version_comment |
The version comment for this table
TYPE:
|
is_latest_version |
If this is the latest version of the object.
TYPE:
|
is_search_enabled |
When creating or updating a table or view specifies if full text search should be enabled. Note that enabling full text search might slow down the indexing of the table or view.
TYPE:
|
annotations |
Additional metadata associated with the table. The key is the name of your desired annotations. The value is an object containing a list of values (use empty list to represent no values for key) and the value type associated with all values in the list.
TYPE:
|
Source code in synapseclient/models/table.py
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 432 433 434 435 436 437 438 439 440 441 442 443 444 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 492 493 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 519 520 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 547 548 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 620 621 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 680 681 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 | |
Functions¶
get_async(synapse_client=None)
async
¶
Get the metadata about the table from synapse.
| PARAMETER | DESCRIPTION |
|---|---|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Table
|
The Table instance stored in synapse. |
Source code in synapseclient/models/table.py
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 | |
store_schema_async(synapse_client=None)
async
¶
Store non-row information about a table including the columns and annotations.
| PARAMETER | DESCRIPTION |
|---|---|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Table
|
The Table instance stored in synapse. |
Source code in synapseclient/models/table.py
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 620 621 622 623 624 625 626 627 628 629 | |
store_rows_from_csv_async(csv_path, synapse_client=None)
async
¶
Takes in a path to a CSV and stores the rows to Synapse.
| PARAMETER | DESCRIPTION |
|---|---|
csv_path
|
The path to the CSV to store.
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
The path to the CSV that was stored. |
Source code in synapseclient/models/table.py
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | |
delete_rows_async(rows, synapse_client=None)
async
¶
Delete rows from a table.
| PARAMETER | DESCRIPTION |
|---|---|
rows
|
The rows to delete.
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
None
|
None |
Source code in synapseclient/models/table.py
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 | |
query_async(query, result_format=CsvResultFormat(), synapse_client=None)
async
classmethod
¶
Query for data on a table stored in Synapse.
| PARAMETER | DESCRIPTION |
|---|---|
query
|
The query to run.
TYPE:
|
result_format
|
The format of the results. Defaults to CsvResultFormat().
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Union[CsvFileTable, TableQueryResult]
|
The results of the query. |
Source code in synapseclient/models/table.py
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 | |
delete_async(synapse_client=None)
async
¶
Delete the table from synapse.
| PARAMETER | DESCRIPTION |
|---|---|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
None
|
None |
Source code in synapseclient/models/table.py
659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 | |
get_permissions_async(synapse_client=None)
async
¶
Get the permissions that the caller has on an Entity.
| PARAMETER | DESCRIPTION |
|---|---|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Permissions
|
A Permissions object |
Using this function:
Getting permissions for a Synapse Entity
permissions = await File(id="syn123").get_permissions_async()
Getting access types list from the Permissions object
permissions.access_types
Source code in synapseclient/models/mixins/access_control.py
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 | |
get_acl_async(principal_id=None, synapse_client=None)
async
¶
Get the ACL that a user or group has on an Entity.
| PARAMETER | DESCRIPTION |
|---|---|
principal_id
|
Identifier of a user or group (defaults to PUBLIC users)
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
List[str]
|
An array containing some combination of ['READ', 'UPDATE', 'CREATE', 'DELETE', 'DOWNLOAD', 'MODERATE', 'CHANGE_PERMISSIONS', 'CHANGE_SETTINGS'] or an empty array |
Source code in synapseclient/models/mixins/access_control.py
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 | |
set_permissions_async(principal_id=None, access_type=None, modify_benefactor=False, warn_if_inherits=True, overwrite=True, synapse_client=None)
async
¶
Sets permission that a user or group has on an Entity. An Entity may have its own ACL or inherit its ACL from a benefactor.
| PARAMETER | DESCRIPTION |
|---|---|
principal_id
|
Identifier of a user or group.
TYPE:
|
access_type
|
Type of permission to be granted. One or more of CREATE, READ, DOWNLOAD, UPDATE, DELETE, CHANGE_PERMISSIONS. Defaults to ['READ', 'DOWNLOAD']
TYPE:
|
modify_benefactor
|
Set as True when modifying a benefactor's ACL
TYPE:
|
warn_if_inherits
|
Set as False, when creating a new ACL. Trying to modify the ACL of an Entity that inherits its ACL will result in a warning
TYPE:
|
overwrite
|
By default this function overwrites existing permissions for the specified user. Set this flag to False to add new permissions non-destructively.
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Dict[str, Union[str, list]]
|
An Access Control List object |
Setting permissions
Grant all registered users download access
await File(id="syn123").set_permissions_async(principal_id=273948, access_type=['READ','DOWNLOAD'])
Grant the public view access
await File(id="syn123").set_permissions_async(principal_id=273949, access_type=['READ'])
Source code in synapseclient/models/mixins/access_control.py
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 157 158 159 160 161 162 | |
synapseclient.models.Activity
dataclass
¶
Bases: ActivitySynchronousProtocol
An activity is a Synapse object that helps to keep track of what objects were used
in an analysis step, as well as what objects were generated. Thus, all relationships
between Synapse objects and an activity are governed by dependencies. That is, an
activity needs to know what it used, and outputs need to know what activity
they were generatedBy.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
The unique immutable ID for this actvity.
TYPE:
|
name |
A name for this Activity.
TYPE:
|
description |
A description for this Activity.
TYPE:
|
etag |
Synapse employs an Optimistic Concurrency Control (OCC) scheme to handle concurrent updates. Since the E-Tag changes every time an entity is updated it is used to detect when a client's current representation of an entity is out-of-date.
TYPE:
|
created_on |
The date this object was created.
TYPE:
|
modified_on |
The date this object was last modified.
TYPE:
|
created_by |
The user that created this object.
TYPE:
|
modified_by |
The user that last modified this object.
TYPE:
|
used |
The entities or URLs used by this Activity.
TYPE:
|
executed |
The entities or URLs executed by this Activity.
TYPE:
|
Source code in synapseclient/models/activity.py
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 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 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 232 233 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 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 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 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 | |
Functions¶
from_parent_async(parent, synapse_client=None)
async
classmethod
¶
Get the Activity from Synapse based on the parent entity.
| PARAMETER | DESCRIPTION |
|---|---|
parent
|
The parent entity this activity is associated with. The parent may also have a version_number. Gets the most recent version if version is omitted. |
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Union[Activity, None]
|
The activity object or None if it does not exist. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the parent does not have an ID. |
Source code in synapseclient/models/activity.py
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 | |
store_async(parent=None, synapse_client=None)
async
¶
Store the Activity in Synapse.
| PARAMETER | DESCRIPTION |
|---|---|
parent
|
The parent entity to associate this activity with. |
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Activity
|
The activity object. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
Raised if both of the following are true:
|
Source code in synapseclient/models/activity.py
230 231 232 233 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 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 | |
delete_async(parent, synapse_client=None)
async
classmethod
¶
Delete the Activity from Synapse. The Activity must be disassociated from all entities before it can be deleted. The first step of this delete call is to disassociate the Activity from the parent entity. If you have other entities that are associated with this Activity you must disassociate them by calling this method on them as well. You'll receive an error for all entities until the last one which will delete the Activity.
| PARAMETER | DESCRIPTION |
|---|---|
parent
|
The parent entity this activity is associated with. |
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the parent does not have an ID. |
Source code in synapseclient/models/activity.py
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 | |
synapseclient.models.Team
dataclass
¶
Bases: TeamSynchronousProtocol
Represents a Synapse Team. User definable fields are:
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
The ID of the team
TYPE:
|
name |
The name of the team
TYPE:
|
description |
A short description of the team
TYPE:
|
icon |
A file handle ID for the icon image of the team
TYPE:
|
can_public_join |
True if members can join without an invitation or approval
TYPE:
|
can_request_membership |
True if users can create a membership request to join
TYPE:
|
etag |
Synapse employs an Optimistic Concurrency Control (OCC) scheme to handle concurrent updates Since the E-Tag changes every time an entity is updated it is used to detect when a client's current representation of an entity is out-of-date.
TYPE:
|
created_on |
The date this team was created
TYPE:
|
modified_on |
The date this team was last modified
TYPE:
|
created_by |
The ID of the user that created this team
TYPE:
|
modified_by |
The ID of the user that last modified this team
TYPE:
|
Source code in synapseclient/models/team.py
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 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 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 232 233 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 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 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 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 | |
Functions¶
create_async(synapse_client=None)
async
¶
Creates a new team on Synapse.
| PARAMETER | DESCRIPTION |
|---|---|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Team
|
The Team object.
TYPE:
|
Source code in synapseclient/models/team.py
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 171 172 | |
delete_async(synapse_client=None)
async
¶
Deletes a team from Synapse.
| PARAMETER | DESCRIPTION |
|---|---|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
None
|
None |
Source code in synapseclient/models/team.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 | |
from_id_async(id, synapse_client=None)
async
classmethod
¶
Gets Team object using its integer id.
| PARAMETER | DESCRIPTION |
|---|---|
id
|
The id of the team.
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Team
|
The Team object.
TYPE:
|
Source code in synapseclient/models/team.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
from_name_async(name, synapse_client=None)
async
classmethod
¶
Gets Team object using its string name.
*** You will be unable to retrieve a team by name immediately after its creation because the fragment service is eventually consistent. If you need to retrieve a team immediately following creation you should use the [from_id][synapseclient.models.Team.from_id] method. ***
| PARAMETER | DESCRIPTION |
|---|---|
name
|
The name of the team.
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Team
|
The Team object.
TYPE:
|
Source code in synapseclient/models/team.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
members_async(synapse_client=None)
async
¶
Gets the TeamMembers associated with a team given the ID field on the Team instance.
| PARAMETER | DESCRIPTION |
|---|---|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
List[TeamMember]
|
List[TeamMember]: A List of TeamMember objects. |
Source code in synapseclient/models/team.py
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 | |
invite_async(user, message, force=True, synapse_client=None)
async
¶
Invites a user to a team given the ID field on the Team instance.
| PARAMETER | DESCRIPTION |
|---|---|
user
|
The username of the user to invite.
TYPE:
|
message
|
The message to send.
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict
|
The invite response.
TYPE:
|
Source code in synapseclient/models/team.py
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 | |
open_invitations_async(synapse_client=None)
async
¶
Gets all open invitations for a team given the ID field on the Team instance.
| PARAMETER | DESCRIPTION |
|---|---|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
List[Dict[str, str]]
|
List[dict]: A list of invitations. |
Source code in synapseclient/models/team.py
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 | |
synapseclient.models.UserProfile
dataclass
¶
Bases: UserProfileSynchronousProtocol
UserProfile represents a user's profile in the system.
| ATTRIBUTE | DESCRIPTION |
|---|---|
id |
A foreign key to the ID of the 'principal' object for the user.
TYPE:
|
etag |
Synapse employs an Optimistic Concurrency Control (OCC) scheme to handle concurrent updates. Since the E-Tag changes every time an entity is updated it is used to detect when a client's currentrepresentation of an entity is out-of-date.
TYPE:
|
first_name |
This person's given name (forename)
TYPE:
|
last_name |
This person's family name (surname)
TYPE:
|
emails |
The list of user email addresses registered to this user.
TYPE:
|
open_ids |
The list of OpenIds bound to this user's account.
TYPE:
|
username |
A name chosen by the user that uniquely identifies them.
TYPE:
|
display_name |
This field is deprecated and will always be null.
TYPE:
|
r_studio_url |
URL for RStudio server assigned to the user.
TYPE:
|
summary |
A summary description about this person.
TYPE:
|
position |
This person's current position title.
TYPE:
|
location |
This person's location.
TYPE:
|
industry |
The industry/discipline that this person is associated with.
TYPE:
|
company |
This person's current affiliation.
TYPE:
|
profile_picure_file_handle_id |
The File Handle id of the user's profile picture.
TYPE:
|
url |
A link to more information about this person.
TYPE:
|
team_name |
This person's default team name.
TYPE:
|
notification_settings |
Contains a user's notification settings.
TYPE:
|
preferences |
User preferences
TYPE:
|
created_on |
The date this profile was created.
TYPE:
|
Source code in synapseclient/models/user.py
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 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 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 232 233 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 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 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 363 | |
Functions¶
get_async(synapse_client=None)
async
¶
Gets a UserProfile object using its id or username in that order. If an id and username is not specified this will retrieve the current user's profile.
| PARAMETER | DESCRIPTION |
|---|---|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
UserProfile
|
The UserProfile object. |
Source code in synapseclient/models/user.py
229 230 231 232 233 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 278 279 280 281 282 283 | |
from_id_async(user_id, synapse_client=None)
async
classmethod
¶
Gets UserProfile object using its integer id. Wrapper for the [get][synapseclient.models.UserProfile.get] method.
| PARAMETER | DESCRIPTION |
|---|---|
user_id
|
The id of the user.
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
UserProfile
|
The UserProfile object. |
Source code in synapseclient/models/user.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
from_username_async(username, synapse_client=None)
async
classmethod
¶
Gets UserProfile object using its string name. Wrapper for the [get][synapseclient.models.UserProfile.get] method.
| PARAMETER | DESCRIPTION |
|---|---|
username
|
A name chosen by the user that uniquely identifies them.
TYPE:
|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
UserProfile
|
The UserProfile object. |
Source code in synapseclient/models/user.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 | |
is_certified_async(synapse_client=None)
async
¶
Determine whether a user is certified.
| PARAMETER | DESCRIPTION |
|---|---|
synapse_client
|
If not passed in or None this will use the last client
from the
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if the user is certified, False otherwise. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If id nor username is specified. |
Source code in synapseclient/models/user.py
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 363 | |