Skip to content

Commit f7627e0

Browse files
committed
add function to update filehandle for a version
1 parent f168622 commit f7627e0

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

synapseclient/api/entity_services.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,3 +1726,37 @@ async def main():
17261726
return True
17271727
raise
17281728
return True
1729+
1730+
1731+
async def update_entity_file_handle_version(
1732+
entity_id: str,
1733+
version: int,
1734+
old_file_handle_id: str,
1735+
new_file_handle_id: str,
1736+
*,
1737+
synapse_client: Optional["Synapse"] = None,
1738+
) -> None:
1739+
"""Update the file handle for a specific version of an entity.
1740+
1741+
Arguments:
1742+
entity_id: The Synapse ID of the entity.
1743+
version: The version number to update.
1744+
old_file_handle_id: The file handle ID being replaced.
1745+
new_file_handle_id: The new file handle ID to assign.
1746+
synapse_client: If not passed in and caching was not disabled by
1747+
`Synapse.allow_client_caching(False)` this will use the last created
1748+
instance from the Synapse class constructor.
1749+
"""
1750+
from synapseclient import Synapse
1751+
1752+
client = Synapse.get_client(synapse_client=synapse_client)
1753+
client.logger.info(f"Updating file handle for {entity_id} version {version}")
1754+
await client.rest_put_async(
1755+
f"/entity/{entity_id}/version/{version}/filehandle",
1756+
body=json.dumps(
1757+
{
1758+
"oldFileHandleId": old_file_handle_id,
1759+
"newFileHandleId": new_file_handle_id,
1760+
}
1761+
),
1762+
)

0 commit comments

Comments
 (0)