diff --git a/CHANGELOG.md b/CHANGELOG.md index d168b98c6e488fd99ee4670c4495e07b62ab08d5..905c01c160979eec7279aef095cdc348def1fa4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Support for Python 3.12 * The `linkahead` module now opts into type checking and supports mypy. +* [#112](https://gitlab.com/linkahead/linkahead-pylib/-/issues/112) + `Entity.update_acl` now supports optional `**kwargs` that are passed to the + `Entity.update` method that is called internally, thus allowing, e.g., + updating the ACL despite possible naming collisions with `unique=False`. ### Changed ### diff --git a/src/linkahead/common/models.py b/src/linkahead/common/models.py index ba42b972856205cd73f9e1e654edbb6f0b09efbc..abcf0b2da57398a318b092cabd70bee1af1b790c 100644 --- a/src/linkahead/common/models.py +++ b/src/linkahead/common/models.py @@ -1450,7 +1450,30 @@ out: List[Entity] self.acl = Entity(name=self.name, id=self.id).retrieve( flags={"ACL": None}).acl - def update_acl(self): + def update_acl(self, **kwargs): + """Update this entity's ACL on the server. + + A typical workflow is to first edit ``self.acl`` and then call this + method. + + Note + ---- + This overwrites any existing ACL, so you may want to run + ``retrieve_acl`` before updating the ACL in this entity. + + Parameters + ---------- + **kwargs : dict + Keyword arguments that are passed through to the + ``Entity.update`` method. Useful for e.g. ``unique=False`` in the + case of naming collisions. + + Returns + ------- + e : Entity + This entity after the update of the ACL. + + """ if self.id is None: c = Container().retrieve(query=self.name, sync=False) @@ -1473,7 +1496,7 @@ out: List[Entity] if self.acl is None: raise EntityHasNoAclError("This entity does not have an ACL yet. Please set one first.") e.acl = ACL(self.acl.to_xml()) - e.update() + e.update(**kwargs) return e