Перейти к содержанию

WebhookGateway class

Warning

The current page still doesn't have a translation for this language.

But you can help translating it: Contributing.

This is the reference for the WebhookGateway that contains all the parameters, attributes and functions.

How to import

from esmerald import WebhookGateway

esmerald.WebhookGateway

WebhookGateway(*, handler, name=None, include_in_schema=True, parent=None, deprecated=None, security=None, tags=None)

Bases: Path, Dispatcher, GatewayUtil

WebhookGateway object class used by Esmerald routes.

The WebhookGateway act as a brigde between the webhook handlers and the main Esmerald routing system.

Read more about WebhookGateway and how to use it.

Note

This is used for OpenAPI documentation purposes only.

PARAMETER DESCRIPTION
handler

An instance of handler.

TYPE: Union[WebhookHandler, View]

name

The name for the WebhookGateway.

TYPE: Optional[str] DEFAULT: None

include_in_schema

Boolean flag indicating if it should be added to the OpenAPI docs.

TYPE: bool DEFAULT: True

parent

Who owns the Gateway. If not specified, the application automatically it assign it.

This is directly related with the application levels.

TYPE: Optional[ParentType] DEFAULT: None

deprecated

Boolean flag for indicating the deprecation of the Gateway and to display it in the OpenAPI documentation..

TYPE: Optional[bool] DEFAULT: None

security

Used by OpenAPI definition, the security must be compliant with the norms. Esmerald offers some out of the box solutions where this is implemented.

The Esmerald security is available to automatically used.

The security can be applied also on a level basis.

For custom security objects, you must subclass esmerald.openapi.security.base.HTTPBase object.

TYPE: Optional[Sequence[SecurityScheme]] DEFAULT: None

tags

A list of strings tags to be applied to the path operation.

It will be added to the generated OpenAPI documentation.

Note almost everything in Esmerald can be done in levels, which means these tags on a Esmerald instance, means it will be added to every route even if those routes also contain tags.

TYPE: Optional[Sequence[str]] DEFAULT: None

Source code in esmerald/routing/gateways.py
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
def __init__(
    self,
    *,
    handler: Annotated[
        Union["WebhookHandler", View],
        Doc(
            """
            An instance of [handler](https://esmerald.dev/routing/webhooks/#handlers).
            """
        ),
    ],
    name: Annotated[
        Optional[str],
        Doc(
            """
            The name for the WebhookGateway.
            """
        ),
    ] = None,
    include_in_schema: Annotated[
        bool,
        Doc(
            """
            Boolean flag indicating if it should be added to the OpenAPI docs.
            """
        ),
    ] = True,
    parent: Annotated[
        Optional["ParentType"],
        Doc(
            """
            Who owns the Gateway. If not specified, the application automatically it assign it.

            This is directly related with the [application levels](https://esmerald.dev/application/levels/).
            """
        ),
    ] = None,
    deprecated: Annotated[
        Optional[bool],
        Doc(
            """
            Boolean flag for indicating the deprecation of the Gateway and to display it
            in the OpenAPI documentation..
            """
        ),
    ] = None,
    security: Annotated[
        Optional[Sequence["SecurityScheme"]],
        Doc(
            """
            Used by OpenAPI definition, the security must be compliant with the norms.
            Esmerald offers some out of the box solutions where this is implemented.

            The [Esmerald security](https://esmerald.dev/openapi/) is available to automatically used.

            The security can be applied also on a [level basis](https://esmerald.dev/application/levels/).

            For custom security objects, you **must** subclass
            `esmerald.openapi.security.base.HTTPBase` object.
            """
        ),
    ] = None,
    tags: Annotated[
        Optional[Sequence[str]],
        Doc(
            """
            A list of strings tags to be applied to the *path operation*.

            It will be added to the generated OpenAPI documentation.

            **Note** almost everything in Esmerald can be done in [levels](https://esmerald.dev/application/levels/), which means
            these tags on a Esmerald instance, means it will be added to every route even
            if those routes also contain tags.
            """
        ),
    ] = None,
) -> None:
    if is_class_and_subclass(handler, View):
        handler = handler(parent=self)  # type: ignore

    self.path = handler.path
    self.methods = getattr(handler, "http_methods", None)

    if not name:
        if not isinstance(handler, View):
            name = clean_string(handler.fn.__name__)
        else:
            name = clean_string(handler.__class__.__name__)

    self.handler = cast("Callable", handler)
    self.include_in_schema = include_in_schema

    self._interceptors: Union[List["Interceptor"], "VoidType"] = Void
    self.name = name
    self.dependencies: Any = {}
    self.interceptors: Sequence["Interceptor"] = []
    self.permissions: Sequence["Permission"] = []  # type: ignore
    self.middleware: Any = []
    self.exception_handlers: Any = {}
    self.response_class = None
    self.response_cookies = None
    self.response_headers = None
    self.deprecated = deprecated
    self.parent = parent
    self.security = security
    self.tags = tags or []
    (handler.path_regex, handler.path_format, handler.param_convertors, _) = compile_path(
        self.path
    )

    if self.is_handler(self.handler):  # type: ignore
        self.handler.name = self.name

        if not handler.operation_id:
            handler.operation_id = self.generate_operation_id(
                name=self.name, handler=self.handler  # type: ignore
            )

handler instance-attribute

handler = cast('Callable', handler)

name instance-attribute

name = name

include_in_schema instance-attribute

include_in_schema = include_in_schema

parent instance-attribute

parent = parent

deprecated instance-attribute

deprecated = deprecated

security instance-attribute

security = security

tags instance-attribute

tags = tags or []