Skip to content

WebhookConfig

Base classes

Name Children Inherits
EventSourceConfig
evented_config.configs
Base configuration for event sources.

⋔ Inheritance diagram

graph TD
  4245672194["configs.WebhookConfig"]
  711273161["configs.EventSourceConfig"]
  330168112["schema.Schema"]
  3879467795["main.BaseModel"]
  2751680898["builtins.object"]
  711273161 --> 4245672194
  330168112 --> 711273161
  3879467795 --> 330168112
  2751680898 --> 3879467795

🛈 DocStrings

Bases: EventSourceConfig

Webhook event source.

Source code in src/evented_config/configs.py
class WebhookConfig(EventSourceConfig):
    """Webhook event source."""

    type: Literal["webhook"] = Field("webhook", init=False)
    """webhook-based event."""

    host: str = Field(
        default="127.0.0.1",
        examples=["127.0.0.1", "0.0.0.0"],
        title="Listen host",
    )
    """Interface to bind to. Loopback by default; set a secret when binding a public one."""

    port: int = Field(examples=[8080, 9000, 3000], title="Listen port", ge=1, lt=65536)
    """Port to listen on."""

    path: str = Field(
        examples=["/webhook", "/api/events", "/github-webhook"],
        title="URL path",
    )
    """URL path to handle requests."""

    secret: SecretStr | None = Field(
        default=None,
        examples=["webhook_secret_123", "github_webhook_key"],
        title="Validation secret",
    )
    """Optional secret for request validation (HMAC signature, see the docs)."""

    model_config = ConfigDict(json_schema_extra={"x-doc-title": "Webhook"})

    def get_event_source(self) -> WebhookEventSource:
        """Create webhook event source instance."""
        from evented.webhook_watcher import WebhookEventSource

        return WebhookEventSource(config=self)

host class-attribute instance-attribute

host: str = Field(default='127.0.0.1', examples=['127.0.0.1', '0.0.0.0'], title='Listen host')

Interface to bind to. Loopback by default; set a secret when binding a public one.

path class-attribute instance-attribute

path: str = Field(examples=['/webhook', '/api/events', '/github-webhook'], title='URL path')

URL path to handle requests.

port class-attribute instance-attribute

port: int = Field(examples=[8080, 9000, 3000], title='Listen port', ge=1, lt=65536)

Port to listen on.

secret class-attribute instance-attribute

secret: SecretStr | None = Field(
    default=None, examples=["webhook_secret_123", "github_webhook_key"], title="Validation secret"
)

Optional secret for request validation (HMAC signature, see the docs).

type class-attribute instance-attribute

type: Literal['webhook'] = Field('webhook', init=False)

webhook-based event.

get_event_source

get_event_source() -> WebhookEventSource

Create webhook event source instance.

Source code in src/evented_config/configs.py
def get_event_source(self) -> WebhookEventSource:
    """Create webhook event source instance."""
    from evented.webhook_watcher import WebhookEventSource

    return WebhookEventSource(config=self)

:fa-brands-github: Show source on GitHub