[docs]defset_permissions(project:str,registry:str,staging:str,url:str,asset:Optional[str]=None,owners:Optional[List]=None,uploaders:Optional[List]=None,global_write:Optional[bool]=None,append:bool=True,):""" Set the owner and uploader permissions for a project or an asset within a project. Args: project: Name of the project. registry: Path to the Gobbler registry. staging: Path to the staging directory. url: URL to the Gobbler REST API. asset: Name of the asset inside the project. If supplied, permissions are set on this asset rather than the entire project. owners: List of user IDs for owners of this project. If ``None``, no change is made to the existing owners in the project permissions. uploaders: List of dictionaries specifying the authorized uploaders for this project. Each dictionary should follow the same format as the ``uploaders`` field in the return value of :py:func:`~gobbler.fetch_permissions.fetch_permissions`. If ``None``, no change is made to the existing uploaders. global_write: Whether to enable global writes for this project, see the ``global_write`` field in the return value of :py:func:`~gobbler.fetch_permissions.fetch_permissions` for more details. If ``None``, no change is made to the global write status. Ignored if ``asset`` is provided. append: Whether ``owners`` and ``uploaders`` should be appended to the existing owners and uploaders, respectively. If ``False``, the ``owners`` and ``uploaders`` are used to replace the existing values in the project permissions. """perms={}ifappend:oldperms=fetch_permissions(project,asset=asset,registry=registry,url=url)ifownersisnotNone:oldset=set(oldperms["owners"])perms["owners"]=oldperms["owners"]+list(filter(lambdax:xnotinoldset,owners))ifuploadersisnotNone:perms["uploaders"]=oldperms["uploaders"]+uploaderselse:ifownersisnotNone:perms["owners"]=ownersifuploadersisnotNone:perms["uploaders"]=uploaderspayload={"project":project}ifassetisnotNone:payload["asset"]=assetelifglobal_writeisnotNone:perms["global_write"]=global_writepayload["permissions"]=permsut.dump_request(staging,url,"set_permissions",payload)