Skip to content

Commit

Permalink
feat!: ClientFileActionsの対象のIDを指定する引数を削除 #140
Browse files Browse the repository at this point in the history
  • Loading branch information
yupix committed Jun 18, 2024
1 parent 61257ad commit 9d9b509
Showing 1 changed file with 6 additions and 29 deletions.
35 changes: 6 additions & 29 deletions mipac/actions/drive/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,14 @@ async def update(
class ClientFileActions(SharedFileActions):
def __init__(self, file_ids: str, *, session: HTTPClient, client: ClientManager):
super().__init__(session=session, client=client)
self.__file_ids: str = file_ids
self.__file_ids: str = file_ids # TODO: 何故複数形なのか確認する

@override
async def get_attached_notes(
self,
since_id: str | None = None,
until_id: str | None = None,
limit: int = 10,
*,
file_id: str | None = None,
) -> list[Note]:
"""Get the attached notes of a file
Expand All @@ -184,18 +182,14 @@ async def get_attached_notes(
The id of the note to end at, defaults to None
limit: int
The amount of notes to get, defaults to 10
file_id: str | None
The id of the file to get notes from, defaults to None
Returns
-------
list[Note]
The attached notes of the file
"""
file_id = file_id or self.__file_ids

return await super().get_attached_notes(
since_id=since_id, until_id=until_id, limit=limit, file_id=file_id
since_id=since_id, until_id=until_id, limit=limit, file_id=self.__file_ids
)

@override
Expand All @@ -204,35 +198,24 @@ async def get_all_attached_notes(
since_id: str | None = None,
until_id: str | None = None,
limit: int = 10,
*,
file_id: str | None = None,
) -> AsyncGenerator[Note, None]:
file_id = file_id or self.__file_ids

async for note in super().get_all_attached_notes(
since_id=since_id, until_id=until_id, limit=limit, file_id=file_id
since_id=since_id, until_id=until_id, limit=limit, file_id=self.__file_ids
):
yield note

@override
async def delete(self, *, file_id: str | None = None) -> bool:
async def delete(self) -> bool:
"""指定したファイルIDのファイルを削除します
Endpoint: `/api/drive/files/delete`
Parameters
----------
file_id: str | None
対象のファイルID, default=None
Returns
-------
bool
削除に成功したかどうか
"""
file_id = file_id or self.__file_ids

return await super().delete(file_id=file_id)
return await super().delete(file_id=self.__file_ids)

@override
async def update(
Expand All @@ -241,8 +224,6 @@ async def update(
name: str | None = MISSING,
is_sensitive: bool = MISSING,
comment: str | None = MISSING,
*,
file_id: str | None = None,
) -> File:
"""指定したIDのファイル情報を更新します
Expand All @@ -258,22 +239,18 @@ async def update(
ファイルがセンシティブかどうか, default=MISSING
comment: str | None
ファイルのコメント, default=MISSING
file_id: str | None
対象のファイルID, default=None
Returns
-------
File
更新後のファイル
"""
file_id = file_id or self.__file_ids

return await super().update(
folder_id=folder_id,
name=name,
is_sensitive=is_sensitive,
comment=comment,
file_id=file_id,
file_id=self.__file_ids,
)


Expand Down

0 comments on commit 9d9b509

Please sign in to comment.