sqlmesh.core.user
1import typing as t 2from enum import Enum 3 4from sqlmesh.core.notification_target import BasicSMTPNotificationTarget, NotificationTarget 5from sqlmesh.utils.pydantic import PydanticModel, ValidationInfo, field_validator 6 7 8class UserRole(str, Enum): 9 """A role to associate the user with""" 10 11 REQUIRED_APPROVER = "required_approver" 12 13 @property 14 def is_required_approver(self) -> bool: 15 return self == UserRole.REQUIRED_APPROVER 16 17 18class User(PydanticModel): 19 """SQLMesh user information that can be used for notifications""" 20 21 username: str 22 """The name to refer to the user""" 23 github_username: t.Optional[str] = None 24 """The github login username""" 25 slack_username: t.Optional[str] = None 26 """The slack username""" 27 email: t.Optional[str] = None 28 """The email for the user (full address)""" 29 roles: t.List[UserRole] = [] 30 """List of roles to associate with the user""" 31 notification_targets: t.List[NotificationTarget] = [] 32 """List of notification targets""" 33 34 @property 35 def is_required_approver(self) -> bool: 36 """Indicates if this is a required approver for PR approvals.""" 37 return UserRole.REQUIRED_APPROVER in self.roles 38 39 @field_validator("notification_targets") 40 def validate_notification_targets( 41 cls, 42 v: t.List[NotificationTarget], 43 info: ValidationInfo, 44 ) -> t.List[NotificationTarget]: 45 email = info.data["email"] 46 for target in v: 47 if isinstance(target, BasicSMTPNotificationTarget) and target.recipients != {email}: 48 raise ValueError("Recipient emails do not match user email") 49 return v
class
UserRole(builtins.str, enum.Enum):
9class UserRole(str, Enum): 10 """A role to associate the user with""" 11 12 REQUIRED_APPROVER = "required_approver" 13 14 @property 15 def is_required_approver(self) -> bool: 16 return self == UserRole.REQUIRED_APPROVER
A role to associate the user with
REQUIRED_APPROVER =
<UserRole.REQUIRED_APPROVER: 'required_approver'>
Inherited Members
- enum.Enum
- name
- value
- builtins.str
- encode
- replace
- split
- rsplit
- join
- capitalize
- casefold
- title
- center
- count
- expandtabs
- find
- partition
- index
- ljust
- lower
- lstrip
- rfind
- rindex
- rjust
- rstrip
- rpartition
- splitlines
- strip
- swapcase
- translate
- upper
- startswith
- endswith
- removeprefix
- removesuffix
- isascii
- islower
- isupper
- istitle
- isspace
- isdecimal
- isdigit
- isnumeric
- isalpha
- isalnum
- isidentifier
- isprintable
- zfill
- format
- format_map
- maketrans
19class User(PydanticModel): 20 """SQLMesh user information that can be used for notifications""" 21 22 username: str 23 """The name to refer to the user""" 24 github_username: t.Optional[str] = None 25 """The github login username""" 26 slack_username: t.Optional[str] = None 27 """The slack username""" 28 email: t.Optional[str] = None 29 """The email for the user (full address)""" 30 roles: t.List[UserRole] = [] 31 """List of roles to associate with the user""" 32 notification_targets: t.List[NotificationTarget] = [] 33 """List of notification targets""" 34 35 @property 36 def is_required_approver(self) -> bool: 37 """Indicates if this is a required approver for PR approvals.""" 38 return UserRole.REQUIRED_APPROVER in self.roles 39 40 @field_validator("notification_targets") 41 def validate_notification_targets( 42 cls, 43 v: t.List[NotificationTarget], 44 info: ValidationInfo, 45 ) -> t.List[NotificationTarget]: 46 email = info.data["email"] 47 for target in v: 48 if isinstance(target, BasicSMTPNotificationTarget) and target.recipients != {email}: 49 raise ValueError("Recipient emails do not match user email") 50 return v
SQLMesh user information that can be used for notifications
notification_targets: List[Annotated[Union[sqlmesh.core.notification_target.BasicSMTPNotificationTarget, sqlmesh.core.notification_target.GenericNotificationTarget, sqlmesh.core.notification_target.ConsoleNotificationTarget, sqlmesh.core.notification_target.SlackApiNotificationTarget, sqlmesh.core.notification_target.SlackWebhookNotificationTarget], FieldInfo(annotation=NoneType, required=True, discriminator='type_')]]
List of notification targets
is_required_approver: bool
35 @property 36 def is_required_approver(self) -> bool: 37 """Indicates if this is a required approver for PR approvals.""" 38 return UserRole.REQUIRED_APPROVER in self.roles
Indicates if this is a required approver for PR approvals.
@field_validator('notification_targets')
def
validate_notification_targets( cls, v: List[Annotated[Union[sqlmesh.core.notification_target.BasicSMTPNotificationTarget, sqlmesh.core.notification_target.GenericNotificationTarget, sqlmesh.core.notification_target.ConsoleNotificationTarget, sqlmesh.core.notification_target.SlackApiNotificationTarget, sqlmesh.core.notification_target.SlackWebhookNotificationTarget], FieldInfo(annotation=NoneType, required=True, discriminator='type_')]], info: pydantic_core.core_schema.ValidationInfo) -> List[Annotated[Union[sqlmesh.core.notification_target.BasicSMTPNotificationTarget, sqlmesh.core.notification_target.GenericNotificationTarget, sqlmesh.core.notification_target.ConsoleNotificationTarget, sqlmesh.core.notification_target.SlackApiNotificationTarget, sqlmesh.core.notification_target.SlackWebhookNotificationTarget], FieldInfo(annotation=NoneType, required=True, discriminator='type_')]]:
40 @field_validator("notification_targets") 41 def validate_notification_targets( 42 cls, 43 v: t.List[NotificationTarget], 44 info: ValidationInfo, 45 ) -> t.List[NotificationTarget]: 46 email = info.data["email"] 47 for target in v: 48 if isinstance(target, BasicSMTPNotificationTarget) and target.recipients != {email}: 49 raise ValueError("Recipient emails do not match user email") 50 return v
model_config =
{'json_encoders': {<class 'sqlglot.expressions.core.Expr'>: <function _expression_encoder>, <class 'sqlglot.expressions.datatypes.DataType'>: <function _expression_encoder>, <class 'sqlglot.expressions.query.Tuple'>: <function _expression_encoder>, typing.Union[sqlglot.expressions.query.Query, sqlmesh.core.dialect.JinjaQuery]: <function _expression_encoder>, typing.Union[sqlglot.expressions.query.Query, sqlmesh.core.dialect.JinjaQuery, sqlmesh.core.dialect.MacroFunc]: <function _expression_encoder>, <class 'datetime.tzinfo'>: <function PydanticModel.<lambda>>}, 'arbitrary_types_allowed': True, 'extra': 'forbid', 'protected_namespaces': ()}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Inherited Members
- pydantic.main.BaseModel
- BaseModel
- model_fields
- model_computed_fields
- model_extra
- model_fields_set
- model_construct
- model_copy
- model_dump
- model_dump_json
- model_json_schema
- model_parametrized_name
- model_post_init
- model_rebuild
- model_validate
- model_validate_json
- model_validate_strings
- parse_file
- from_orm
- construct
- schema
- schema_json
- validate
- update_forward_refs