Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support attachments #26

Merged
merged 2 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: style issues
  • Loading branch information
danfimov committed Sep 30, 2023
commit 93921a298371dbaaf7f03b35efc9c1fb1cacfb4a
2 changes: 1 addition & 1 deletion ya_tracker_client/domain/entities/attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ class Attachment(AbstractEntity):
thumbnail: str | None = None
created_by: UserShort
created_at: datetime
mimetype: str = Field(..., examples=['text/plain', 'image/png'])
mimetype: str = Field(..., examples=["text/plain", "image/png"])
size: int
metadata: AttachmentMetadata | None = None
2 changes: 1 addition & 1 deletion ya_tracker_client/domain/repositories/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from ya_tracker_client.domain.repositories.attachment import AttachmentRepository
from ya_tracker_client.domain.repositories.checklist import ChecklistRepository
from ya_tracker_client.domain.repositories.component import ComponentRepository
from ya_tracker_client.domain.repositories.issue import IssueRepository
from ya_tracker_client.domain.repositories.issue_relationship import IssueRelationshipRepository
from ya_tracker_client.domain.repositories.queue import QueueRepository
from ya_tracker_client.domain.repositories.user import UserRepository
from ya_tracker_client.domain.repositories.worklog import WorklogRepository
from ya_tracker_client.domain.repositories.attachment import AttachmentRepository


__all__ = [
Expand Down
8 changes: 4 additions & 4 deletions ya_tracker_client/domain/repositories/attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from aiohttp import FormData

from ya_tracker_client.domain.repositories.base import EntityRepository
from ya_tracker_client.domain.entities.attachment import Attachment
from ya_tracker_client.domain.repositories.base import EntityRepository


class AttachmentRepository(EntityRepository):
Expand All @@ -14,7 +14,7 @@ async def get_attachments_list(self, issue_id: str) -> list[Attachment]:
YC docs: https://cloud.yandex.com/en/docs/tracker/concepts/issues/get-attachments-list
"""
raw_response = await self._client.request(
method='GET',
method="GET",
uri=f"/issues/{issue_id}/attachments",
)
return self._decode(raw_response, Attachment, plural=True)
Expand All @@ -23,15 +23,15 @@ async def download_attachment(
self,
issue_id: str,
attachment_id: str | int,
filename: str
filename: str,
) -> bytes:
"""
Use this request to download files attached to issues.

YC docs: https://cloud.yandex.com/en/docs/tracker/concepts/issues/get-attachment
"""
return await self._client.request(
method='GET',
method="GET",
uri=f"/issues/{issue_id}/attachments/{attachment_id}/{filename}",
)

Expand Down
2 changes: 1 addition & 1 deletion ya_tracker_client/infrastructure/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from ssl import create_default_context
from typing import Any

from aiohttp import BytesPayload, ClientSession, ClientTimeout, TCPConnector, FormData
from aiohttp import BytesPayload, ClientSession, ClientTimeout, FormData, TCPConnector
from certifi import where

from ya_tracker_client.domain.client import BaseClient
Expand Down
Loading