Skip to main content

A simple notification library for Google Cloud projects. Sends alerts via Email and Google Chat.

Project description

GCP Notifier

A simple notification library for Google Cloud projects. Send alerts via Email and Google Chat with a single function call. Designed to be imported and used as a Python module in your own code.

Features

  • Send notifications via Email and Google Chat (Webhook)
  • Unified, simple Python API: notify(subject, body, channels)
  • Tenacity-compatible error callback: notify_on_failure
  • Secrets are securely loaded from Google Secret Manager

Installation

Install from PyPI (recommended):

pip install gcp-notifier

Or, to test the latest version from TestPyPI:

pip install -i https://test.pypi.org/simple/ gcp-notifier

Or, for local development:

pip install .

Or add to your requirements.txt:

gcp_notifier @ git+https://github.com/marcellusmontilla/gcp_notifier.git

Quick Start

  1. Install the package (see Installation above).

  2. The account (personal or service) running this code must have the 'Secret Manager Secret Accessor' role in your GCP project.

  3. The required secrets must be in the same GCP project where your Python script or notebook is running.

  4. Add your required secrets to Google Secret Manager in your GCP project:

    • GCHAT_WEBHOOK_URL (for Google Chat)
    • EMAIL_SENDER (sender email address for Email)
    • EMAIL_PASSWORD (password or app password for sender)
    • EMAIL_RECIPIENTS (comma-separated list of recipient email addresses)
  5. Import and use notify in your code as shown below.

Usage

Import and use in your Python code:

from gcp_notifier import notify, notify_on_failure

# Send a notification (choose channels: "email", "gchat", or both)
notify(
  subject="Alert Subject",
  body="Alert body text",
  channels=["email", "gchat"]  # or ["email"] or ["gchat"]
)

# Use as tenacity retry_error_callback
from tenacity import retry, stop_after_attempt

@retry(stop=stop_after_attempt(3), retry_error_callback=notify_on_failure)
def always_fails():
  # This function will always fail, triggering notify_on_failure after retries
  raise ValueError("This is a test error for notification.")

always_fails()

Building and Publishing

This project uses a modern Python packaging workflow with pyproject.toml.

To build the package:

python -m pip install --upgrade build
python -m build

To check and upload to PyPI:

python -m pip install --upgrade twine
twine check dist/*
twine upload dist/*

See Python Packaging User Guide for more details.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gcp_notifier-0.1.2.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gcp_notifier-0.1.2-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file gcp_notifier-0.1.2.tar.gz.

File metadata

  • Download URL: gcp_notifier-0.1.2.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for gcp_notifier-0.1.2.tar.gz
Algorithm Hash digest
SHA256 65a2e32857dd659a81ae603a94b05653042b2d528d06e8be29703d11834443a1
MD5 6a15e25cad27d7d8144d0c71255ce3ea
BLAKE2b-256 36b410987e28db17613e017f46f7274f35e510ef09dc725b36d0b608c1ed17f6

See more details on using hashes here.

File details

Details for the file gcp_notifier-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: gcp_notifier-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for gcp_notifier-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1db60e4a740a14e56b2083db6d2e32eb03e95ca28616983c1c9d9e6dc29f76a6
MD5 9511def56ba22650c345706fbb7d24f4
BLAKE2b-256 939f08d9b40d5ac3c9688f6fab3017a242634aa78409d77dbce2dec84d46d35d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page