octomachinery.github.models.events module¶

Generic GitHub event containers.

class octomachinery.github.models.events.GitHubEvent(name: str, payload: Mapping[str, Any] | bytes | str)[source]¶

Bases: object

Representation of a generic source-agnostic GitHub event.

async dispatch_via(*routers: OctomachineryRouterBase, ctx: Mapping[str, Any] | None = None) → Iterable[Any][source]¶

Invoke this event handlers from different routers.

classmethod from_file(event_name: str, event_path: Path | str) → GitHubEvent[source]¶

Construct a GitHubEvent instance from event name and file.

classmethod from_fixture(event_fixture_path: Path | str, *, event: str | None = None) → GitHubEvent[source]¶

Make a GitHubEvent from a fixture and an optional name.

classmethod from_fixture_fd(event_fixture_fd: TextIO, *, event: str | None = None) → GitHubEvent[source]¶

Make a GitHubEvent from a fixture fd and an optional name.

classmethod from_gidgethub(event: Event) → GitHubEvent[source]¶

Construct GitHubEvent from from GidgetHub Event.

name: str¶

Event name.

payload: Mapping[str, Any]¶

Event payload object.

to_gidgethub() → Event[source]¶

Produce GidgetHub Event from self.

class octomachinery.github.models.events.GitHubWebhookEvent(name: str, payload: Mapping[str, Any] | bytes | str, delivery_id: str | UUID)[source]¶

Bases: GitHubEvent

Representation of a GitHub event arriving by HTTP.

delivery_id: UUID¶

A unique UUID4 identifier of the event delivery on GH side.

classmethod from_file(event_name: str, event_path: Path | str) → GitHubWebhookEvent[source]¶

Explode when constructing from file.

classmethod from_fixture(event_fixture_path: Path | str, *, event: str | None = None) → GitHubWebhookEvent[source]¶

Make a GitHubWebhookEvent from fixture and optional name.

classmethod from_fixture_fd(event_fixture_fd: TextIO, *, event: str | None = None) → GitHubWebhookEvent[source]¶

Make GitHubWebhookEvent from fixture fd and optional name.

classmethod from_gidgethub(event: Event) → GitHubWebhookEvent[source]¶

Construct GitHubWebhookEvent from from GidgetHub Event.

classmethod from_http_request(http_req_headers: Mapping[str, str], http_req_body: bytes) → GitHubWebhookEvent[source]¶

Make a GitHubWebhookEvent from HTTP req headers and body.

to_gidgethub() → Event[source]¶

Produce GidgetHub Event from self.