How to use the fastapi.params.Query function in fastapi

To help you get started, we’ve selected a few fastapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github luckydonald / pytgbot / code_generation / output / telegram_bot_api_server / funcs.py View on Github external
async def send_video_note(
    token: str = TOKEN_VALIDATION,
    chat_id: Union[int, str] = Query(..., description='Unique identifier for the target chat or username of the target channel (in the format @channelusername)'),
    video_note: Union['InputFileModel', str] = Query(..., description='Video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. More info on Sending Files ». Sending video notes by a URL is currently unsupported'),
    duration: Optional[int] = Query(None, description='Duration of sent video in seconds'),
    length: Optional[int] = Query(None, description='Video width and height, i.e. diameter of the video message'),
    thumb: Union[Optional['InputFileModel'], Optional[str]] = Query(None, description='Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320. Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file, so you can pass "attach://" if the thumbnail was uploaded using multipart/form-data under . More info on Sending Files »'),
    disable_notification: Optional[bool] = Query(None, description='Sends the message silently. Users will receive a notification with no sound.'),
    reply_to_message_id: Optional[int] = Query(None, description='If the message is a reply, ID of the original message'),
    reply_markup: Union[Optional['InlineKeyboardMarkupModel'], Optional['ReplyKeyboardMarkupModel'], Optional['ReplyKeyboardRemoveModel'], Optional['ForceReplyModel']] = Query(None, description='Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.'),
) -> JSONableResponse:
    """
    As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long. Use this method to send video messages. On success, the sent Message is returned.

    https://core.telegram.org/bots/api#sendvideonote
    """
    from ....main import _get_bot
    bot = await _get_bot(token)
    
    try:
github luckydonald / pytgbot / code_generation / output / telegram_bot_api_server / funcs.py View on Github external
payload: str = Query(..., description='Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.'),
    provider_token: str = Query(..., description='Payments provider token, obtained via Botfather'),
    start_parameter: str = Query(..., description='Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter'),
    currency: str = Query(..., description='Three-letter ISO 4217 currency code, see more on currencies'),
    prices: List['LabeledPriceModel'] = Query(..., description='Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)'),
    provider_data: Optional[str] = Query(None, description='JSON-encoded data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.'),
    photo_url: Optional[str] = Query(None, description='URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for.'),
    photo_size: Optional[int] = Query(None, description='Photo size'),
    photo_width: Optional[int] = Query(None, description='Photo width'),
    photo_height: Optional[int] = Query(None, description='Photo height'),
    need_name: Optional[bool] = Query(None, description="Pass True, if you require the user's full name to complete the order"),
    need_phone_number: Optional[bool] = Query(None, description="Pass True, if you require the user's phone number to complete the order"),
    need_email: Optional[bool] = Query(None, description="Pass True, if you require the user's email address to complete the order"),
    need_shipping_address: Optional[bool] = Query(None, description="Pass True, if you require the user's shipping address to complete the order"),
    send_phone_number_to_provider: Optional[bool] = Query(None, description="Pass True, if user's phone number should be sent to provider"),
    send_email_to_provider: Optional[bool] = Query(None, description="Pass True, if user's email address should be sent to provider"),
    is_flexible: Optional[bool] = Query(None, description='Pass True, if the final price depends on the shipping method'),
    disable_notification: Optional[bool] = Query(None, description='Sends the message silently. Users will receive a notification with no sound.'),
    reply_to_message_id: Optional[int] = Query(None, description='If the message is a reply, ID of the original message'),
    reply_markup: Optional['InlineKeyboardMarkupModel'] = Query(None, description="A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button."),
) -> JSONableResponse:
    """
    Use this method to send invoices. On success, the sent Message is returned.

    https://core.telegram.org/bots/api#sendinvoice
    """
    from ....main import _get_bot
    bot = await _get_bot(token)
    
    try:
        entity = await get_entity(bot, chat_id)
    except BotMethodInvalidError:
github luckydonald / pytgbot / code_generation / output / telegram_bot_api_server / funcs.py View on Github external
async def send_invoice(
    token: str = TOKEN_VALIDATION,
    chat_id: int = Query(..., description='Unique identifier for the target private chat'),
    title: str = Query(..., description='Product name, 1-32 characters'),
    description: str = Query(..., description='Product description, 1-255 characters'),
    payload: str = Query(..., description='Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.'),
    provider_token: str = Query(..., description='Payments provider token, obtained via Botfather'),
    start_parameter: str = Query(..., description='Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter'),
    currency: str = Query(..., description='Three-letter ISO 4217 currency code, see more on currencies'),
    prices: List['LabeledPriceModel'] = Query(..., description='Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)'),
    provider_data: Optional[str] = Query(None, description='JSON-encoded data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.'),
    photo_url: Optional[str] = Query(None, description='URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for.'),
    photo_size: Optional[int] = Query(None, description='Photo size'),
    photo_width: Optional[int] = Query(None, description='Photo width'),
    photo_height: Optional[int] = Query(None, description='Photo height'),
    need_name: Optional[bool] = Query(None, description="Pass True, if you require the user's full name to complete the order"),
    need_phone_number: Optional[bool] = Query(None, description="Pass True, if you require the user's phone number to complete the order"),
    need_email: Optional[bool] = Query(None, description="Pass True, if you require the user's email address to complete the order"),
    need_shipping_address: Optional[bool] = Query(None, description="Pass True, if you require the user's shipping address to complete the order"),
    send_phone_number_to_provider: Optional[bool] = Query(None, description="Pass True, if user's phone number should be sent to provider"),
    send_email_to_provider: Optional[bool] = Query(None, description="Pass True, if user's email address should be sent to provider"),
    is_flexible: Optional[bool] = Query(None, description='Pass True, if the final price depends on the shipping method'),
    disable_notification: Optional[bool] = Query(None, description='Sends the message silently. Users will receive a notification with no sound.'),
    reply_to_message_id: Optional[int] = Query(None, description='If the message is a reply, ID of the original message'),
    reply_markup: Optional['InlineKeyboardMarkupModel'] = Query(None, description="A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button."),
) -> JSONableResponse:
    """
    Use this method to send invoices. On success, the sent Message is returned.
github luckydonald / pytgbot / code_generation / output / telegram_bot_api_server / funcs.py View on Github external
async def create_new_sticker_set(
    token: str = TOKEN_VALIDATION,
    user_id: int = Query(..., description='User identifier of created sticker set owner'),
    name: str = Query(..., description='Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can\'t contain consecutive underscores and must end in "_by_".  is case insensitive. 1-64 characters.'),
    title: str = Query(..., description='Sticker set title, 1-64 characters'),
    png_sticker: Union['InputFileModel', str] = Query(..., description='Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More info on Sending Files »'),
    emojis: str = Query(..., description='One or more emoji corresponding to the sticker'),
    contains_masks: Optional[bool] = Query(None, description='Pass True, if a set of mask stickers should be created'),
    mask_position: Optional['MaskPositionModel'] = Query(None, description='A JSON-serialized object for position where the mask should be placed on faces'),
) -> JSONableResponse:
    """
    Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set. Returns True on success.

    https://core.telegram.org/bots/api#createnewstickerset
    """
    from ....main import _get_bot
    bot = await _get_bot(token)
    

    result = await bot.create_new_sticker_set(
        user_id=user_id,
        name=name,
github luckydonald / pytgbot / code_generation / output / telegram_bot_api_server / funcs.py View on Github external
async def send_invoice(
    token: str = TOKEN_VALIDATION,
    chat_id: int = Query(..., description='Unique identifier for the target private chat'),
    title: str = Query(..., description='Product name, 1-32 characters'),
    description: str = Query(..., description='Product description, 1-255 characters'),
    payload: str = Query(..., description='Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.'),
    provider_token: str = Query(..., description='Payments provider token, obtained via Botfather'),
    start_parameter: str = Query(..., description='Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter'),
    currency: str = Query(..., description='Three-letter ISO 4217 currency code, see more on currencies'),
    prices: List['LabeledPriceModel'] = Query(..., description='Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)'),
    provider_data: Optional[str] = Query(None, description='JSON-encoded data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.'),
    photo_url: Optional[str] = Query(None, description='URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for.'),
    photo_size: Optional[int] = Query(None, description='Photo size'),
    photo_width: Optional[int] = Query(None, description='Photo width'),
    photo_height: Optional[int] = Query(None, description='Photo height'),
    need_name: Optional[bool] = Query(None, description="Pass True, if you require the user's full name to complete the order"),
    need_phone_number: Optional[bool] = Query(None, description="Pass True, if you require the user's phone number to complete the order"),
    need_email: Optional[bool] = Query(None, description="Pass True, if you require the user's email address to complete the order"),
    need_shipping_address: Optional[bool] = Query(None, description="Pass True, if you require the user's shipping address to complete the order"),
    send_phone_number_to_provider: Optional[bool] = Query(None, description="Pass True, if user's phone number should be sent to provider"),
    send_email_to_provider: Optional[bool] = Query(None, description="Pass True, if user's email address should be sent to provider"),
    is_flexible: Optional[bool] = Query(None, description='Pass True, if the final price depends on the shipping method'),
    disable_notification: Optional[bool] = Query(None, description='Sends the message silently. Users will receive a notification with no sound.'),
    reply_to_message_id: Optional[int] = Query(None, description='If the message is a reply, ID of the original message'),
    reply_markup: Optional['InlineKeyboardMarkupModel'] = Query(None, description="A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button."),
) -> JSONableResponse:
    """
    Use this method to send invoices. On success, the sent Message is returned.

    https://core.telegram.org/bots/api#sendinvoice
    """
    from ....main import _get_bot
github luckydonald / pytgbot / code_generation / output / telegram_bot_api_server / funcs.py View on Github external
async def send_invoice(
    token: str = TOKEN_VALIDATION,
    chat_id: int = Query(..., description='Unique identifier for the target private chat'),
    title: str = Query(..., description='Product name, 1-32 characters'),
    description: str = Query(..., description='Product description, 1-255 characters'),
    payload: str = Query(..., description='Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.'),
    provider_token: str = Query(..., description='Payments provider token, obtained via Botfather'),
    start_parameter: str = Query(..., description='Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter'),
    currency: str = Query(..., description='Three-letter ISO 4217 currency code, see more on currencies'),
    prices: List['LabeledPriceModel'] = Query(..., description='Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)'),
    provider_data: Optional[str] = Query(None, description='JSON-encoded data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.'),
    photo_url: Optional[str] = Query(None, description='URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for.'),
    photo_size: Optional[int] = Query(None, description='Photo size'),
    photo_width: Optional[int] = Query(None, description='Photo width'),
    photo_height: Optional[int] = Query(None, description='Photo height'),
    need_name: Optional[bool] = Query(None, description="Pass True, if you require the user's full name to complete the order"),
    need_phone_number: Optional[bool] = Query(None, description="Pass True, if you require the user's phone number to complete the order"),
    need_email: Optional[bool] = Query(None, description="Pass True, if you require the user's email address to complete the order"),
    need_shipping_address: Optional[bool] = Query(None, description="Pass True, if you require the user's shipping address to complete the order"),
    send_phone_number_to_provider: Optional[bool] = Query(None, description="Pass True, if user's phone number should be sent to provider"),
    send_email_to_provider: Optional[bool] = Query(None, description="Pass True, if user's email address should be sent to provider"),
    is_flexible: Optional[bool] = Query(None, description='Pass True, if the final price depends on the shipping method'),
    disable_notification: Optional[bool] = Query(None, description='Sends the message silently. Users will receive a notification with no sound.'),
    reply_to_message_id: Optional[int] = Query(None, description='If the message is a reply, ID of the original message'),
    reply_markup: Optional['InlineKeyboardMarkupModel'] = Query(None, description="A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button."),
) -> JSONableResponse:
    """
    Use this method to send invoices. On success, the sent Message is returned.

    https://core.telegram.org/bots/api#sendinvoice
github luckydonald / pytgbot / code_generation / output / telegram_bot_api_server / funcs.py View on Github external
async def send_contact(
    token: str = TOKEN_VALIDATION,
    chat_id: Union[int, str] = Query(..., description='Unique identifier for the target chat or username of the target channel (in the format @channelusername)'),
    phone_number: str = Query(..., description="Contact's phone number"),
    first_name: str = Query(..., description="Contact's first name"),
    last_name: Optional[str] = Query(None, description="Contact's last name"),
    vcard: Optional[str] = Query(None, description='Additional data about the contact in the form of a vCard, 0-2048 bytes'),
    disable_notification: Optional[bool] = Query(None, description='Sends the message silently. Users will receive a notification with no sound.'),
    reply_to_message_id: Optional[int] = Query(None, description='If the message is a reply, ID of the original message'),
    reply_markup: Union[Optional['InlineKeyboardMarkupModel'], Optional['ReplyKeyboardMarkupModel'], Optional['ReplyKeyboardRemoveModel'], Optional['ForceReplyModel']] = Query(None, description='Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove keyboard or to force a reply from the user.'),
) -> JSONableResponse:
    """
    Use this method to send phone contacts. On success, the sent Message is returned.

    https://core.telegram.org/bots/api#sendcontact
    """
    from ....main import _get_bot
    bot = await _get_bot(token)
    
    try:
        entity = await get_entity(bot, chat_id)
github luckydonald / pytgbot / code_generation / output / telegram_bot_api_server / funcs.py View on Github external
async def promote_chat_member(
    token: str = TOKEN_VALIDATION,
    chat_id: Union[int, str] = Query(..., description='Unique identifier for the target chat or username of the target channel (in the format @channelusername)'),
    user_id: int = Query(..., description='Unique identifier of the target user'),
    can_change_info: Optional[bool] = Query(None, description='Pass True, if the administrator can change chat title, photo and other settings'),
    can_post_messages: Optional[bool] = Query(None, description='Pass True, if the administrator can create channel posts, channels only'),
    can_edit_messages: Optional[bool] = Query(None, description='Pass True, if the administrator can edit messages of other users and can pin messages, channels only'),
    can_delete_messages: Optional[bool] = Query(None, description='Pass True, if the administrator can delete messages of other users'),
    can_invite_users: Optional[bool] = Query(None, description='Pass True, if the administrator can invite new users to the chat'),
    can_restrict_members: Optional[bool] = Query(None, description='Pass True, if the administrator can restrict, ban or unban chat members'),
    can_pin_messages: Optional[bool] = Query(None, description='Pass True, if the administrator can pin messages, supergroups only'),
    can_promote_members: Optional[bool] = Query(None, description='Pass True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him)'),
) -> JSONableResponse:
    """
    Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Pass False for all boolean parameters to demote a user. Returns True on success.

    https://core.telegram.org/bots/api#promotechatmember
    """
    from ....main import _get_bot
    bot = await _get_bot(token)
    
    try:
        entity = await get_entity(bot, chat_id)
    except BotMethodInvalidError:
        assert isinstance(chat_id, int) or (isinstance(chat_id, str) and len(chat_id) > 0 and chat_id[0] == '@')
        entity = chat_id
    except ValueError:
        raise HTTPException(404, detail="chat not found?")
github luckydonald / pytgbot / code_generation / output / telegram_bot_api_server / funcs.py View on Github external
async def set_chat_title(
    token: str = TOKEN_VALIDATION,
    chat_id: Union[int, str] = Query(..., description='Unique identifier for the target chat or username of the target channel (in the format @channelusername)'),
    title: str = Query(..., description='New chat title, 1-255 characters'),
) -> JSONableResponse:
    """
    Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.

    https://core.telegram.org/bots/api#setchattitle
    """
    from ....main import _get_bot
    bot = await _get_bot(token)
    
    try:
        entity = await get_entity(bot, chat_id)
    except BotMethodInvalidError:
        assert isinstance(chat_id, int) or (isinstance(chat_id, str) and len(chat_id) > 0 and chat_id[0] == '@')
        entity = chat_id
    except ValueError:
        raise HTTPException(404, detail="chat not found?")