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.*"))

Metadata

Release files for microsoft-teams-common 2.1.1

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.1
File Size Uploaded
microsoft_teams_common-2.1.1.tar.gz 12.1 kB Details

Built distribution (wheel)

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

Total release size: 29.8 kB

Release files / microsoft_teams_common-2.1.1.tar.gz

Download URL microsoft_teams_common-2.1.1.tar.gz
Size 12.1 kB
Tags Source
SHA-256 checksum
How to use checksums
506857ffcc1deadc0212ba9c633ae0d0052b5c702ae908f06485c9657d652f55
BLAKE2b-256 checksum
How to use checksums
5813dad758a38c1a1e30a26b11be6a0aa1d593b82f3d77ff4092e6fad836deb0
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.1-py3-none-any.whl

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

Release history Release notifications | RSS feed

This release

2.1.1 This release

2 release files

2.1.0

2 release files

2.0.16

2 release files

2.0.12

2 release files

2.0.11

2 release files

2.0.0

2 release files

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