Skip to content

Commit

Permalink
implement Lockable.unlock
Browse files Browse the repository at this point in the history
Mutation.unlockLockable field
  • Loading branch information
ShineyDev committed Feb 16, 2025
1 parent b5d963f commit 9ca9b5a
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
15 changes: 15 additions & 0 deletions github/core/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
/,
Expand Down
28 changes: 28 additions & 0 deletions github/interfaces/lockable.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 9ca9b5a

Please sign in to comment.