Esempio n. 1
0
class PollVoteNewObject(pydantic.BaseModel):
    owner_id: int = pydantic.Field(None, description="")
    poll_id: int = pydantic.Field(None, description="")
    option_id: int = pydantic.Field(None, description="")
    user_id: int = pydantic.Field(None, description="")
Esempio n. 2
0
class MessageNew(BaseBotEvent):
    object: MessageNewObject = pydantic.Field(None, description="")
Esempio n. 3
0
class MessageTypingStateObject(pydantic.BaseModel):
    state: str = pydantic.Field(None, description="")
    from_id: int = pydantic.Field(None, description="")
    to_id: int = pydantic.Field(None, description="")
Esempio n. 4
0
class OptionVarsSchema(BaseModel):
    name: str
    deprecated: DeprecationSchema = p.Field({})
    version_added: str = 'historical'
    version_added_collection: str = COLLECTION_NAME_F
Esempio n. 5
0
class Images(BaseModel):
    data: Optional[List[str]] = pydantic.Field(default=None, example=None, description='List of base64 encoded images')
    urls: Optional[List[str]] = pydantic.Field(default=None,
                                               example=[example_img],
                                               description='List of images urls')
Esempio n. 6
0
class Settings(pydantic.BaseSettings):
    postgres: PostgresSettings = pydantic.Field(
        default_factory=PostgresSettings)
Esempio n. 7
0
class PluginOptionsSchema(OptionsSchema):
    env: t.List[OptionEnvSchema] = []
    ini: t.List[OptionIniSchema] = []
    suboptions: t.Dict[str, 'PluginOptionsSchema'] = {}
    vars: t.List[OptionVarsSchema] = []
    deprecated: DeprecationSchema = p.Field({})
Esempio n. 8
0
class GroupChangeSettings(BaseBotEvent):
    object: GroupChangeSettingsObject = pydantic.Field(None, description="")
Esempio n. 9
0
class GroupChangePhotoObject(pydantic.BaseModel):
    user_id: int = pydantic.Field(None, description="")
    photo: PhotosPhoto = pydantic.Field(None, description="")
Esempio n. 10
0
class ChangesSettingsModel(pydantic.BaseModel):
    old_value: int = pydantic.Field(None, description="")
    new_value: int = pydantic.Field(None, description="")
Esempio n. 11
0
class GroupChangeSettingsObject(pydantic.BaseModel):
    user_id: int = pydantic.Field(None, description="")
    changes: typing.Dict[str,
                         ChangesSettingsModel] = pydantic.Field(None,
                                                                description="")
Esempio n. 12
0
class GroupOfficersEdit(BaseBotEvent):
    object: GroupOfficersEditObject = pydantic.Field(None, description="")
Esempio n. 13
0
class GroupOfficersEditObject(pydantic.BaseModel):
    admin_id: int = pydantic.Field(None, description="")
    level_old: GroupLevelEnum = pydantic.Field(None, description="")
    level_new: GroupLevelEnum = pydantic.Field(None, description="")
    user_id: int = pydantic.Field(None, description="")
Esempio n. 14
0
class PollVoteNew(BaseBotEvent):
    object: PollVoteNewObject = pydantic.Field(None, description="")
Esempio n. 15
0
class LikeRemove(BaseBotEvent):
    object: LikeRemoveEventObject = pydantic.Field(None, description="")
Esempio n. 16
0
class GroupChangePhoto(BaseBotEvent):
    object: GroupChangePhotoObject = pydantic.Field(None, description="")
Esempio n. 17
0
class ClientInfo(pydantic.BaseModel):
    button_actions: typing.List[str] = pydantic.Field(None, description="")
    keyboard: bool = pydantic.Field(None, description="")
    inline_keyboard: bool = pydantic.Field(None, description="")
    carousel: bool = pydantic.Field(None, description="")
    lang_id: int = pydantic.Field(None, description="")
Esempio n. 18
0
class VkpayTransactionObject(pydantic.BaseModel):
    from_id: int = pydantic.Field(None, description="")
    amount: int = pydantic.Field(None, description="")
    description: str = pydantic.Field(None, description="")
    date: int = pydantic.Field(None, description="")
Esempio n. 19
0
class QueueFreezePayload(pydantic.BaseModel):
    reason: str = pydantic.Field(description="The reason of the queue freeze")
Esempio n. 20
0
class VkpayTransaction(BaseBotEvent):
    object: VkpayTransactionObject = pydantic.Field(None, description="")
Esempio n. 21
0
class OptionEnvSchema(BaseModel):
    name: str = REQUIRED_ENV_VAR_F
    deprecated: DeprecationSchema = p.Field({})
    version_added: str = 'historical'
    version_added_collection: str = COLLECTION_NAME_F
Esempio n. 22
0
class AppPayloadObject(pydantic.BaseModel):
    user_id: int = pydantic.Field(None, description="")
    app_id: int = pydantic.Field(None, description="")
    payload: typing.Dict[str, str] = pydantic.Field(None, description="")
    group_id: int = pydantic.Field(None, description="")
Esempio n. 23
0
 class UserModel(pydantic.BaseModel):
     age_: int = pydantic.Field(..., alias="age")
     password: Optional[str]
Esempio n. 24
0
class AppPayload(BaseBotEvent):
    object: AppPayloadObject = pydantic.Field(None, description="")
Esempio n. 25
0
class BaseSnowflakeConfig(BaseTimeWindowConfig):
    # Note: this config model is also used by the snowflake-usage source.

    scheme: str = "snowflake"
    username: Optional[str] = pydantic.Field(
        default=None, description="Snowflake username."
    )
    password: Optional[pydantic.SecretStr] = pydantic.Field(
        default=None, exclude=True, description="Snowflake password."
    )
    private_key_path: Optional[str] = pydantic.Field(
        default=None,
        description="The path to the private key if using key pair authentication. See: https://docs.snowflake.com/en/user-guide/key-pair-auth.html",
    )
    private_key_password: Optional[pydantic.SecretStr] = pydantic.Field(
        default=None,
        exclude=True,
        description="Password for your private key if using key pair authentication.",
    )
    authentication_type: str = pydantic.Field(
        default="DEFAULT_AUTHENTICATOR",
        description='The type of authenticator to use when connecting to Snowflake. Supports "DEFAULT_AUTHENTICATOR", "EXTERNAL_BROWSER_AUTHENTICATOR" and "KEY_PAIR_AUTHENTICATOR".',
    )
    host_port: Optional[str] = pydantic.Field(
        description="DEPRECATED: Snowflake account. e.g. abc48144"
    )  # Deprecated
    account_id: Optional[str] = pydantic.Field(
        description="Snowflake account. e.g. abc48144"
    )  # Once host_port is removed this will be made mandatory
    warehouse: Optional[str] = pydantic.Field(description="Snowflake warehouse.")
    role: Optional[str] = pydantic.Field(description="Snowflake role.")
    include_table_lineage: bool = pydantic.Field(
        default=True,
        description="If enabled, populates the snowflake table-to-table and s3-to-snowflake table lineage. Requires appropriate grants given to the role.",
    )
    include_view_lineage: bool = pydantic.Field(
        default=True,
        description="If enabled, populates the snowflake view->table and table->view lineages (no view->view lineage yet). Requires appropriate grants given to the role, and include_table_lineage to be True.",
    )
    connect_args: Optional[Dict] = pydantic.Field(
        default=None,
        description="Connect args to pass to Snowflake SqlAlchemy driver",
        exclude=True,
    )
    check_role_grants: bool = pydantic.Field(
        default=False,
        description="If set to True then checks role grants at the beginning of the ingestion run. To be used for debugging purposes. If you think everything is working fine then set it to False. In some cases this can take long depending on how many roles you might have.",
    )

    def get_account(self) -> str:
        assert self.account_id
        return self.account_id

    @pydantic.root_validator
    def one_of_host_port_or_account_id_is_required(cls, values):
        host_port = values.get("host_port")
        if host_port is not None:
            logger.warning(
                "snowflake's `host_port` option has been deprecated; use account_id instead"
            )
            host_port = remove_protocol(host_port)
            host_port = remove_trailing_slashes(host_port)
            host_port = remove_suffix(host_port, ".snowflakecomputing.com")
            values["host_port"] = host_port
        account_id = values.get("account_id")
        if account_id is None:
            if host_port is None:
                raise ConfigurationError(
                    "One of account_id (recommended) or host_port (deprecated) is required"
                )
            else:
                values["account_id"] = host_port
        return values

    @pydantic.validator("authentication_type", always=True)
    def authenticator_type_is_valid(cls, v, values, **kwargs):
        if v not in VALID_AUTH_TYPES.keys():
            raise ValueError(
                f"unsupported authenticator type '{v}' was provided,"
                f" use one of {list(VALID_AUTH_TYPES.keys())}"
            )
        else:
            if v == "KEY_PAIR_AUTHENTICATOR":
                # If we are using key pair auth, we need the private key path and password to be set
                if values.get("private_key_path") is None:
                    raise ValueError(
                        f"'private_key_path' was none "
                        f"but should be set when using {v} authentication"
                    )
            logger.info(f"using authenticator type '{v}'")
        return v

    @pydantic.validator("include_view_lineage")
    def validate_include_view_lineage(cls, v, values):
        if not values.get("include_table_lineage") and v:
            raise ValueError(
                "include_table_lineage must be True for include_view_lineage to be set."
            )
        return v

    def get_sql_alchemy_url(
        self,
        database: Optional[str] = None,
        username: Optional[str] = None,
        password: Optional[pydantic.SecretStr] = None,
        role: Optional[str] = None,
    ) -> str:
        if username is None:
            username = self.username
        if password is None:
            password = self.password
        if role is None:
            role = self.role
        return make_sqlalchemy_uri(
            self.scheme,
            username,
            password.get_secret_value() if password else None,
            self.account_id,
            f'"{database}"' if database is not None else database,
            uri_opts={
                # Drop the options if value is None.
                key: value
                for (key, value) in {
                    "authenticator": VALID_AUTH_TYPES.get(self.authentication_type),
                    "warehouse": self.warehouse,
                    "role": role,
                    "application": APPLICATION_NAME,
                }.items()
                if value
            },
        )

    def get_sql_alchemy_connect_args(self) -> dict:
        if self.authentication_type != "KEY_PAIR_AUTHENTICATOR":
            return {}
        if self.connect_args is None:
            if self.private_key_path is None:
                raise ValueError("missing required private key path to read key from")
            if self.private_key_password is None:
                raise ValueError("missing required private key password")
            with open(self.private_key_path, "rb") as key:
                p_key = serialization.load_pem_private_key(
                    key.read(),
                    password=self.private_key_password.get_secret_value().encode(),
                    backend=default_backend(),
                )

            pkb = p_key.private_bytes(
                encoding=serialization.Encoding.DER,
                format=serialization.PrivateFormat.PKCS8,
                encryption_algorithm=serialization.NoEncryption(),
            )
            self.connect_args = {"private_key": pkb}
        return self.connect_args
Esempio n. 26
0
class CallbackButtonEventObject(pydantic.BaseModel):
    conversation_message_id: int = pydantic.Field(None, description="")
    user_id: int = pydantic.Field(None, description="")
    peer_id: int = pydantic.Field(None, description="")
    payload: typing.Dict[str, str] = pydantic.Field(None, description="")
    event_id: str = pydantic.Field(None, description="")
Esempio n. 27
0
class MessageEdit(BaseBotEvent):
    object: MessagesMessage = pydantic.Field(None, description="")
Esempio n. 28
0
class CallbackButtonEvent(BaseBotEvent):
    object: CallbackButtonEventObject = pydantic.Field(None, description="")
Esempio n. 29
0
class MessageTypingState(BaseBotEvent):
    object: MessageTypingStateObject = pydantic.Field(None, description="")
Esempio n. 30
0
class UserUnblock(BaseBotEvent):
    object: UserUnblockObject = pydantic.Field(None, description="")