From 9ca9b5ac50aa723a6b14f6e1883c87d35ec8d5a2 Mon Sep 17 00:00:00 2001 From: Riley Shaw <30989490+ShineyDev@users.noreply.github.com> Date: Sun, 16 Feb 2025 19:20:32 +0000 Subject: [PATCH] implement Lockable.unlock Mutation.unlockLockable field --- github/core/http.py | 15 +++++++++++++++ github/interfaces/lockable.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/github/core/http.py b/github/core/http.py index 19a4ed2..b145026 100644 --- a/github/core/http.py +++ b/github/core/http.py @@ -2582,6 +2582,21 @@ async def mutate_lockable_lock( return data # type: ignore + async def mutate_lockable_unlock( + self, + /, + lockable_id: str, + *, + fields: Iterable[str] = MISSING, + ) -> LockableData: + fields = ("__typename",) if fields is MISSING else fields + query = "mutation($lockable_id:ID!,$mutation_id:String!){unlockLockable(input:{clientMutationId:$mutation_id,lockableId:$lockable_id}){unlockedRecord{%s}}}" % ",".join(fields) + path = ("unlockLockable", "unlockedRecord") + + data = await self._mutate(query, *path, lockable_id=lockable_id) + + return data # type: ignore + async def mutate_reactable_add_reaction( self, /, diff --git a/github/interfaces/lockable.py b/github/interfaces/lockable.py index 4caff4e..71e3b23 100644 --- a/github/interfaces/lockable.py +++ b/github/interfaces/lockable.py @@ -147,6 +147,34 @@ async def lock( self._data["activeLockReason"] = data["activeLockReason"] self._data["locked"] = data["locked"] + async def unlock( + self, + /, + ) -> None: + """ + |coro| + + Unlocks the lockable. + + .. note:: + + Use of this mutation will also update the following fields: + + - :attr:`~.is_locked` + - :attr:`~.locked_reason` + """ + + if TYPE_CHECKING and not isinstance(self, Node): + raise NotImplementedError + + data = await self._http.mutate_lockable_unlock( + self.id, + fields=("activeLockReason", "locked"), + ) + + self._data["activeLockReason"] = data["activeLockReason"] + self._data["locked"] = data["locked"] + __all__ = [ "Lockable",