Skip to content

Commit

Permalink
Merge pull request #402 from mesozoic/scan_models
Browse files Browse the repository at this point in the history
Add missing model fields
  • Loading branch information
mesozoic authored Nov 9, 2024
2 parents e11aab2 + 57600d9 commit 530ce53
Show file tree
Hide file tree
Showing 12 changed files with 389 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pyairtable/models/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class AirtableModel(pydantic.BaseModel):
populate_by_name=True,
)

_raw: Any = pydantic.PrivateAttr()
_raw: Dict[str, Any] = pydantic.PrivateAttr()

def __init__(self, **data: Any) -> None:
raw = data.copy()
Expand Down
32 changes: 31 additions & 1 deletion pyairtable/models/comment.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from typing import Dict, Optional
from typing import Dict, List, Optional

import pydantic

Expand Down Expand Up @@ -62,6 +62,12 @@ class Comment(
#: Users or groups that were mentioned in the text.
mentioned: Dict[str, "Mentioned"] = pydantic.Field(default_factory=dict)

#: The comment ID of the parent comment, if this comment is a threaded reply.
parent_comment_id: Optional[str] = None

#: List of reactions to this comment.
reactions: List["Reaction"] = pydantic.Field(default_factory=list)


class Mentioned(AirtableModel):
"""
Expand All @@ -88,4 +94,28 @@ class Mentioned(AirtableModel):
email: Optional[str] = None


class Reaction(AirtableModel):
"""
A reaction to a comment.
"""

class EmojiInfo(AirtableModel):
unicode_character: str

class ReactingUser(AirtableModel):
user_id: str
email: Optional[str] = None
name: Optional[str] = None

emoji_info: EmojiInfo = pydantic.Field(alias="emoji")
reacting_user: ReactingUser

@property
def emoji(self) -> str:
"""
The emoji character used for the reaction.
"""
return chr(int(self.emoji_info.unicode_character, 16))


rebuild_models(vars())
7 changes: 7 additions & 0 deletions pyairtable/models/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ class BaseCollaborators(_Collaborators, url="meta/bases/{base.id}"):

id: str
name: str
created_time: datetime
permission_level: str
workspace_id: str
interfaces: Dict[str, "BaseCollaborators.InterfaceCollaborators"] = _FD()
Expand All @@ -179,6 +180,8 @@ class InterfaceCollaborators(
_Collaborators,
url="meta/bases/{base.id}/interfaces/{key}",
):
id: str
name: str
created_time: datetime
first_publish_time: Optional[datetime] = None
group_collaborators: List["GroupCollaborator"] = _FL()
Expand Down Expand Up @@ -219,6 +222,7 @@ class Info(
created_time: datetime
share_id: str
type: str
can_be_synced: Optional[bool] = None
is_password_protected: bool
block_installation_id: Optional[str] = None
restricted_to_email_domains: List[str] = _FL()
Expand Down Expand Up @@ -434,6 +438,8 @@ class EnterpriseInfo(AirtableModel):
user_ids: List[str]
workspace_ids: List[str]
email_domains: List["EnterpriseInfo.EmailDomain"]
root_enterprise_id: str = pydantic.Field(alias="rootEnterpriseAccountId")
descendant_enterprise_ids: List[str] = _FL(alias="descendantEnterpriseAccountIds")

class EmailDomain(AirtableModel):
email_domain: str
Expand Down Expand Up @@ -559,6 +565,7 @@ class UserInfo(
name: str
email: str
state: str
is_service_account: bool
is_sso_required: bool
is_two_factor_auth_enabled: bool
last_activity_time: Optional[datetime] = None
Expand Down
14 changes: 9 additions & 5 deletions pyairtable/models/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from datetime import datetime
from functools import partial
from hmac import HMAC
from typing import Any, Callable, Dict, Iterator, List, Optional, Union
from typing import Any, Callable, Dict, Iterator, List, Literal, Optional, Union

import pydantic
from typing_extensions import Self as SelfType
Expand Down Expand Up @@ -270,13 +270,17 @@ class Filters(AirtableModel):
watch_schemas_of_field_ids: List[str] = FL()

class SourceOptions(AirtableModel):
form_submission: Optional["WebhookSpecification.FormSubmission"] = None
form_submission: Optional["FormSubmission"] = None
form_page_submission: Optional["FormPageSubmission"] = None

class FormSubmission(AirtableModel):
view_id: str
class FormSubmission(AirtableModel):
view_id: str

class FormPageSubmission(AirtableModel):
page_id: str

class Includes(AirtableModel):
include_cell_values_in_field_ids: List[str] = FL()
include_cell_values_in_field_ids: Union[None, List[str], Literal["all"]] = None
include_previous_cell_values: bool = False
include_previous_field_definitions: bool = False

Expand Down
Loading

0 comments on commit 530ce53

Please sign in to comment.