mirror of
https://github.com/Xtao-Labs/QQ-GitHub-Bot.git
synced 2025-01-30 15:08:54 +00:00
🚧 add github timeline models
This commit is contained in:
parent
abd15f4c4a
commit
4db8f9f8f1
@ -10,8 +10,6 @@
|
||||
"""
|
||||
__author__ = "yanyongyu"
|
||||
|
||||
import time
|
||||
import datetime
|
||||
from typing_extensions import Literal
|
||||
from typing import List, Optional, overload
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
@Author : yanyongyu
|
||||
@Date : 2021-03-11 01:34:31
|
||||
@LastEditors : yanyongyu
|
||||
@LastEditTime : 2021-03-26 16:47:42
|
||||
@LastEditTime : 2021-05-14 01:23:03
|
||||
@Description : None
|
||||
@GitHub : https://github.com/yanyongyu
|
||||
"""
|
||||
@ -13,7 +13,7 @@ __author__ = "yanyongyu"
|
||||
from contextvars import ContextVar
|
||||
from typing import Any, List, Dict, Type, TypeVar, Generic, AsyncIterator
|
||||
|
||||
from pydantic import BaseModel as _BaseModel, Field
|
||||
from pydantic import BaseModel as _BaseModel, Field, parse_obj_as
|
||||
|
||||
from ..request import Requester
|
||||
|
||||
@ -86,7 +86,7 @@ class PaginatedList(AsyncIterator, Generic[C]):
|
||||
response = await self.requester.request_json(*self.args, **self.kwargs)
|
||||
content = response.json()
|
||||
self._contents.extend([
|
||||
self.cls.parse_obj({
|
||||
parse_obj_as(self.cls, {
|
||||
"requester": self.requester,
|
||||
**x
|
||||
}) for x in content
|
||||
@ -100,6 +100,7 @@ from .label import Label
|
||||
from .license import License
|
||||
from .comment import Comment
|
||||
from .hook import Hook, HookConfig
|
||||
from .timeline import TimelineEvent
|
||||
from .permissions import Permissions
|
||||
from .organization import Organization
|
||||
from .repository import LazyRepository, Repository
|
||||
|
@ -4,14 +4,14 @@
|
||||
@Author : yanyongyu
|
||||
@Date : 2021-03-11 16:57:04
|
||||
@LastEditors : yanyongyu
|
||||
@LastEditTime : 2021-03-26 16:20:01
|
||||
@LastEditTime : 2021-05-14 01:45:44
|
||||
@Description : None
|
||||
@GitHub : https://github.com/yanyongyu
|
||||
"""
|
||||
__author__ = "yanyongyu"
|
||||
|
||||
from datetime import datetime
|
||||
from typing import List, Optional
|
||||
from typing import List, Union, Optional
|
||||
|
||||
from pydantic import BaseModel as _BaseModel
|
||||
|
||||
@ -20,6 +20,9 @@ from . import BaseModel, PaginatedList
|
||||
from .user import User
|
||||
from .label import Label
|
||||
from .comment import Comment
|
||||
from .timeline import (TimelineEvent, TimelineEventCommited,
|
||||
TimelineEventCommented, TimelineEventReviewed,
|
||||
TimelineEventRenamed)
|
||||
|
||||
|
||||
class IssuePullRequest(_BaseModel):
|
||||
@ -75,3 +78,20 @@ class Issue(BaseModel):
|
||||
"GET",
|
||||
self.comments_url,
|
||||
headers=headers)
|
||||
|
||||
async def get_timeline(self) -> PaginatedList[TimelineEvent]:
|
||||
"""
|
||||
GET /repo/:full_name/issues/:number/timeline
|
||||
|
||||
https://docs.github.com/en/rest/reference/issues#list-timeline-events-for-an-issue
|
||||
"""
|
||||
headers = {
|
||||
"Accept": "application/vnd.github.mockingbird-preview.full+json"
|
||||
}
|
||||
return PaginatedList(Union[TimelineEventCommited,
|
||||
TimelineEventCommented,
|
||||
TimelineEventReviewed, TimelineEventRenamed],
|
||||
self.requester,
|
||||
"GET",
|
||||
f"{self.url}/timeline",
|
||||
headers=headers)
|
||||
|
120
src/libs/github/models/timeline.py
Normal file
120
src/libs/github/models/timeline.py
Normal file
@ -0,0 +1,120 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@Author : yanyongyu
|
||||
@Date : 2021-05-14 00:57:33
|
||||
@LastEditors : yanyongyu
|
||||
@LastEditTime : 2021-05-14 02:18:47
|
||||
@Description : None
|
||||
@GitHub : https://github.com/yanyongyu
|
||||
"""
|
||||
__author__ = "yanyongyu"
|
||||
|
||||
from datetime import datetime
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import BaseModel as _BaseModel, Field
|
||||
|
||||
from . import BaseModel
|
||||
|
||||
from .user import User
|
||||
|
||||
|
||||
class TimelineEvent(BaseModel):
|
||||
node_id: str
|
||||
event: str
|
||||
|
||||
|
||||
class TimelineEventCommitedUser(_BaseModel):
|
||||
name: str
|
||||
email: str
|
||||
data: datetime
|
||||
|
||||
|
||||
class TimelineEventCommitedTree(_BaseModel):
|
||||
sha: str
|
||||
url: str
|
||||
|
||||
|
||||
class TimelineEventCommitedCommit(_BaseModel):
|
||||
sha: str
|
||||
url: str
|
||||
html_url: str
|
||||
|
||||
|
||||
class TimelineEventCommitedVerification(_BaseModel):
|
||||
verified: bool
|
||||
reason: str
|
||||
signature: str
|
||||
payload: str
|
||||
|
||||
|
||||
class TimelineEventCommited(TimelineEvent):
|
||||
sha: str
|
||||
url: str
|
||||
html_url: str
|
||||
author: TimelineEventCommitedUser
|
||||
committer: TimelineEventCommitedUser
|
||||
tree: TimelineEventCommitedTree
|
||||
message: str
|
||||
parents: List[TimelineEventCommitedCommit]
|
||||
verification: TimelineEventCommitedVerification
|
||||
|
||||
|
||||
class TimelineEventCommented(TimelineEvent):
|
||||
id: int
|
||||
url: str
|
||||
html_url: str
|
||||
issue_url: str
|
||||
user: User
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
author_association: str
|
||||
body: str
|
||||
body_text: Optional[str]
|
||||
body_html: Optional[str]
|
||||
performed_via_github_app: bool
|
||||
actor: User
|
||||
|
||||
|
||||
class TimelineEventReviewedLink(_BaseModel):
|
||||
href: str
|
||||
|
||||
|
||||
class TimelineEventReviewedLinks(_BaseModel):
|
||||
html: TimelineEventReviewedLink
|
||||
pull_request: TimelineEventReviewedLink
|
||||
|
||||
|
||||
class TimelineEventReviewed(TimelineEvent):
|
||||
id: int
|
||||
user: User
|
||||
state: str
|
||||
html_url: str
|
||||
commit_id: str
|
||||
pull_request_url: str
|
||||
author_association: str
|
||||
submitted_at: datetime
|
||||
body: str
|
||||
body_text: Optional[str]
|
||||
body_html: Optional[str]
|
||||
links: TimelineEventReviewedLinks
|
||||
|
||||
|
||||
class TimelineEventRenamedDetail(_BaseModel):
|
||||
to: str
|
||||
from_: str = Field(alias="from")
|
||||
|
||||
class Config:
|
||||
allow_population_by_field_name = True
|
||||
|
||||
|
||||
class TimelineEventRenamed(TimelineEvent):
|
||||
id: int
|
||||
url: str
|
||||
actor: User
|
||||
commit_id: Optional[str]
|
||||
commit_url: Optional[str]
|
||||
created_at: datetime
|
||||
rename: TimelineEventRenamedDetail
|
||||
performed_via_github_app: Optional[bool]
|
Loading…
Reference in New Issue
Block a user