The `google-events` library provides strongly-typed data payload schemas (using `proto-plus`) for various Google Cloud services that emit CloudEvents. It helps developers safely deserialize and interact with event data, ensuring type correctness and reducing runtime errors. The library is actively maintained by Google and sees frequent updates, primarily adding new event types and fields as Google Cloud services evolve.
pip install google-eventsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to deserialize a raw JSON event data payload (e.g., from a Cloud Storage object finalization event) into a `StorageObjectData` object and access its strongly-typed properties.
Install `cloudevents` (`pip install cloudevents`) and use its `CloudEvent` class, then pass the `google-events` data object to `event.data` or deserialize `event.data` using a `google-events` schema.
Explicitly use versioned imports, e.g., `from google.events.cloud.service.vX import EventData` where `vX` matches the event type version you expect.
Always use `EventTypeData.from_json(json_string)` or `EventTypeData.from_dict(dictionary)` for deserialization before accessing event data fields.