Skip to main content

Microsoft Teams Common Utilities

Shared utilities including HTTP client, logging, storage, and event handling. Provides common functionality used across other Teams SDK packages.

Features

  • HTTP Client: Async HTTP client with token support and interceptors
  • Event System: Type-safe event emitter for application lifecycle management
  • Storage: Local storage implementations for key-value and list data
  • Logging: Console logging with formatting and filtering

HTTP Client

from microsoft_teams.common import Client, ClientOptions

# Create HTTP client
client = Client(ClientOptions(
    base_url="https://api.example.com",
    headers={"User-Agent": "Teams-Bot/1.0"}
))

# Make requests
response = await client.get("/users/me")
data = await client.post("/messages", json={"text": "Hello"})

Event System

from microsoft_teams.common import EventEmitter

# Create type-safe event emitter
emitter = EventEmitter[str]()

# Register handler
def handle_message(data: str):
    print(f"Received: {data}")

subscription_id = emitter.on("message", handle_message)

# Emit event
emitter.emit("message", "Hello World")

# Remove handler
emitter.off(subscription_id)

Storage

from microsoft_teams.common import LocalStorage, ListLocalStorage

# Key-value storage
storage = LocalStorage[str]()
storage.set("key", {"data": "value"})
data = storage.get("key")

# Async operations
await storage.async_set("key", {"data": "value"})
data = await storage.async_get("key")

# List storage
list_storage = ListLocalStorage[str]()
list_storage.append("new-item")
items = list_storage.items()

Logging

The SDK uses Python's standard logging module. The library doesn't configure logging - your application should.

import logging

# Configure logging once at application startup
logging.getLogger().setLevel(logging.DEBUG)
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(ConsoleFormatter())
logging.getLogger().addHandler(stream_handler)

# Use module-level loggers in your code
logger = logging.getLogger(__name__)
logger.info("Application started")

Custom Filtering

The SDK provides optional filtering as well:

stream_handler.addFilter(ConsoleFilter("microsoft_teams.*"))

Release files for microsoft-teams-common 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for microsoft-teams-common 2.1.0
File Size Uploaded
microsoft_teams_common-2.1.0.tar.gz 12.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for microsoft-teams-common 2.1.0
File Interpreter ABI Platform
microsoft_teams_common-2.1.0-py3-none-any.whl Python 3 none any Details

Total release size:29.8 kB

Release files / microsoft_teams_common-2.1.0.tar.gz

Download URL microsoft_teams_common-2.1.0.tar.gz
Size 12.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b9babe4ac3d433a19d1f3f5f528849d8e6def0b65f664a4d2509e9bc345baa4a
BLAKE2b-256 checksum
How to use checksums
0c4a2287dd7e4530129b1f35940cde2e4050606164d83823bb47ca719b9cec1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release files / microsoft_teams_common-2.1.0-py3-none-any.whl

Download URL microsoft_teams_common-2.1.0-py3-none-any.whl
Size 17.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
37e4fe660df933a07c1b480e9e1d4cb1361a6a2e716638e98fb1ab674fd6d7a6
BLAKE2b-256 checksum
How to use checksums
a13d45c94e518b2a96a878958bacb76d5402db3406e2105419b31c4f7c2406bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via RestSharp/106.13.0.0

Release history Release notifications | RSS feed

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page